SQL comparison

Hi there! can anyone help me out I need to compare a date from the database and the system date which will be coded in a store procedure in SQL... HELP!!!!!


Answer this question

SQL comparison

  • Rozee

    You may like to reconsider the answer given by Ali. DateTimes in NET are stored to a precision of 100 ns or 0.0000001 seconds whilst those stored by SQL Server in the SQL Server datatype DateTime are stored to the nearest 0.003333 seconds. Therefore you should not use a simple equality operator to compare them. Instead you should compare them based on the lowest precision argument, ie round the NET DateTime to the nearest 0.00333 seconds and then compare them.

    Regards,

    John Whattam.


  • Sorcerer14

    another question please... how can i add days in the getday() function in SQL stored procs

  • wakjah

    You can use the DATEADD function with this syntax

    DATEADD ( datepart , number, date )



  • Daniel Coleman

    Both the dates are of DateTime type, then you can directly compare them with = operator


  • SQL comparison