Home Forums SQL Server 2008 T-SQL (SS2K8) DateDiff help to verify my code is correct or not? RE: DateDiff help to verify my code is correct or not?

  • Dhananjay - did the example and explanation Lynn posted help you understand? The problem with datediff is calculates differences on a boundary. The results is how many of those boundaries are crossed between the two dates. In the example Lynn posted the datediff(DAY...) will return 0 but clearly @date2 > @date1.

    using Predicates comparison for dates is not allowed in my team

    This is obviously based on the fact that your manager does not understand how this type of thing works. You are forbidden to use best way for data comparison. :w00t:

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/