Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use datetime difference in SQL Select?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01390159
Message ID:
01390387
Views:
38
>>>Hi,
>>>
>>>How do you SUM number of days difference between two DateTime type fields as following:
>>>
>>>
>>>select SUM( DATETIME1 - DATETIME2) AS NUMDAYS
>>>
>>
>>SELECT SUM(DATEDIFF(dd, Date1, Date2)) AS NumDays
>>
>
>Borislav,
>
>I am trying to understand the DATEDIFF() function better. Do I understand correctly that the 1st parameter "dd" really has no literal meaning? That is, you can name this parameter anything and it won't change the result?

It has, it means days :-)
As Naomi said it means we wand to get difference in days. Check BOL to see the other values of the first parameter.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform