Conor's Snippet Diary

Friday, 13 November 2009

SQL Server - How do I select just the date portion of a datetime field

There are a few ways to do this, but I find the easiest is to use the float version of a datetime and crop off the decimal portion (right of the decimal place is the time portion)

DECLARE @currentDate DateTime
SET @currentDate = Cast(Floor(Cast(GetDate() as Float )) As DateTime)
Posted by Conor Gallagher at 05:59 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: SQL Server
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Links

  • Microsoft Dynamics CRM Community

Blog Archive

  • ►  2016 (12)
    • ►  October (2)
    • ►  September (2)
    • ►  June (3)
    • ►  May (3)
    • ►  March (1)
    • ►  February (1)
  • ►  2015 (4)
    • ►  December (1)
    • ►  July (1)
    • ►  May (1)
    • ►  January (1)
  • ►  2014 (8)
    • ►  October (2)
    • ►  September (2)
    • ►  June (1)
    • ►  February (1)
    • ►  January (2)
  • ►  2013 (9)
    • ►  September (3)
    • ►  July (1)
    • ►  April (1)
    • ►  March (3)
    • ►  February (1)
  • ►  2012 (14)
    • ►  October (3)
    • ►  August (1)
    • ►  July (3)
    • ►  March (3)
    • ►  February (4)
  • ►  2011 (4)
    • ►  December (1)
    • ►  October (1)
    • ►  September (2)
  • ►  2010 (2)
    • ►  September (1)
    • ►  May (1)
  • ▼  2009 (11)
    • ▼  November (1)
      • SQL Server - How do I select just the date portion...
    • ►  October (3)
    • ►  September (1)
    • ►  August (6)

About Me

My photo
Conor Gallagher
All about Coding, CRM and whatnot.
View my complete profile
Simple theme. Powered by Blogger.