Skip to content

Instantly share code, notes, and snippets.

@jwoschitz
Created September 12, 2011 12:03
Show Gist options
  • Save jwoschitz/1211105 to your computer and use it in GitHub Desktop.
Save jwoschitz/1211105 to your computer and use it in GitHub Desktop.
Get date part in T-SQL
SELECT DATEADD(DAY, 0, DATEDIFF(DAY, 0, GETDATE()))
-- Selects the current date as datetime, e.g. 2011-09-10 00:00:00.000
SELECT CONVERT(VARCHAR(8), GETDATE(), 112)
-- Selects the current date as varchar, e.g. 20110910
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment