In SQL Server how do I isolate just the date portion of a date time field.

I have a field enrollment_date that is on a table in SQL Server.  How do I isolate just the date portion?

I don't want just day, month or year but 08/31/2012.
moriniaAdvanced Analytics AnalystAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
you may want to read up this article:
http://www.experts-exchange.com/Database/Miscellaneous/A_1499-DATE-and-TIME-don%27t-be-scared-and-do-it-right-the-first-time.html

in your case, you have 2 options, based on the fact if you need the date for display or for calculations.
if it's for display:
CONVERT(VARCHAR(10), enrollment_date, 101)

if it's for calculation:
CONVERT(datetime, CONVERT(varchar(10), enrollment_date, 101), 101)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.