Solved

Datediff issue with smalldatetime

Posted on 2012-03-16
1
496 Views
Last Modified: 2012-03-16
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 :)
0
Comment
Question by:ser_berto
1 Comment
 
LVL 26

Accepted Solution

by:
Chris Luttrell earned 500 total points
ID: 37731222
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.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now