Skip to content

Instantly share code, notes, and snippets.

@westonwatson
Created June 6, 2013 12:11
Show Gist options
  • Save westonwatson/5721060 to your computer and use it in GitHub Desktop.
Save westonwatson/5721060 to your computer and use it in GitHub Desktop.
sql datediff example
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