379716 visitors has seen the Tim-Carter.com site. Thanks!
321 visitors has seen the Tim-Carter.com site today.
 
 
Search :  
 
>>> Programming >> MSSQL > How to Calculate the diffence between two dates with SQL? (This page has been seen 699 times)

How to Calculate the diffence between two dates with SQL?

You can calculate the difference between two dates in SQL server with the DATEDIFF command.

Here is an example

SELECT DATEDIFF(Day,StartDate,EndDate) as DAYS FROM MyTable

This would give you the number of dates between the StartDate and the EndDate.

Here is an reference

  • year
  • quarter
  • month
  • dayofyear
  • day
  • week
  • Hour
  • minute
  • second
  • millisecond



Like (3)
 
Dislike (0)


Keywords for this article:
DATEDIFF || DATETIME || SQL || TSQL

Post comment

Name:


Comment:

Code Language:

Code:

Here you can paste a code example. It will then be processed by SyntaxHighlighter and formatted for easier readability.
Please remember to select the correct Code Language in the select above so the SyntaxHighlighter can highlight the code properly.




Code:

Please enter the code you see above

What is 1 + 6 =

Submit Comment


No one has commented on this page yet. You could be the first.


Advertisement by Google


Sponsors :