I am trying some examples for DateDiff Function
SELECT DATEDIFF(day,'2008-06-05','2008-08-05') AS DiffDate
This statement gives me an error From keyword not found where expected.
Why do I get this error and how can I solve it?
Also, when I try this :
SELECT DATEDIFF(day,datebegin,datestop)
From table;
I get this error "datediff" invalid identifier.
How can I get day difference?
What database are you using?
A google search gave me this:
http://www.mssqltips.com/sqlservertip/2508/sql-server-datediff-example/
DAY SELECT DATEDIFF(DD,’09/23/2011 15:00:00′,’08/02/2011 14:00:00′)
where ‘DD’ is used as opposed to ‘days’.
Try answering these question:
What database I’m using?
Is the database case sensitive? This might be the error occurring with the datediff as oppose to DATEDIFF