Skip to content

Instantly share code, notes, and snippets.

@phpleo
Created August 18, 2011 14:03
Show Gist options
  • Save phpleo/1154128 to your computer and use it in GitHub Desktop.
Save phpleo/1154128 to your computer and use it in GitHub Desktop.
SQL DateTime and comparison
-- http://demiliani.com/blog/archive/2006/01/19/3384.aspx
WHERE DateDiff(dd, OrderDate, '01/01/2006') = 0
WHERE Convert(varchar(20), OrderDate, 101) = '01/01/2006'
WHERE Year(OrderDate) = 2006 AND Month(OrderDate) = 1 and Day(OrderDate)=1
WHERE OrderDate LIKE '01/01/2006%'
WHERE OrderDate >= '01/01/2006' AND OrderDate < '01/02/2006'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment