>>> 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
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
Advertisement by Google
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 =