Datediff issue with smalldatetime

I have folowing code:

    SELECT @daysAgo=DATEDIFF(dd,LDatum, @LDatum) from LeistungenListe 

Open in new window

In DB LDatum has value '2011-07-04 00:00:00' now when I specify in my application as a date '2011-07-04 01:00:00' it returns me 1 day.

However when I specify '2011-07-03 12:00:00' I get 0 days. So it seems that somehow time 00:00 is treated as 23:59.

Is it right behaviour? How I can fix this without easy + 1 :)
Who is Participating?
Chris LuttrellConnect With a Mentor Senior Database ArchitectCommented:
Check that you are not having a problem with timezone changes from your application to the database.  When tested straight in the databases the DATEDIFF functions correctly with both your test cases.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.