Created
June 6, 2013 12:11
-
-
Save westonwatson/5721060 to your computer and use it in GitHub Desktop.
sql datediff example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
CAST(DATEDIFF(d, GETDATE(), GETDATE()+1) AS VARCHAR) + ':' + | |
CAST(DATEDIFF(hh, GETDATE(), GETDATE()+1) AS VARCHAR) + ':' + | |
CAST(DATEDIFF(mi, GETDATE(), GETDATE()+1) AS VARCHAR) + ':' + | |
CAST(DATEDIFF(ss, GETDATE(), GETDATE()+1) AS VARCHAR) | |
--"d" will give you difference in Days | |
--"hh" will give you difference in Hours | |
--"mi" will give you difference in Minutes | |
--"ss" will give you difference in Seconds. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment