Extracting Date from Datetime

My database is SQl SERVER 2005.

I have a question about extracting just the date from date time, my end result must be date formatted excluding time.
For example - My date is 08/18/2009 12:00 AM, I just want to extract 08/18/2009 and this must be in Date format. I can use DATEPART function and finally cast it, but then I’m getting 08/18/2009 00:00:000

The requirement is that, users want to see only date.

Appreciate all your inputs. Thanks for reading this post.


BIDeveloper (BOB member since 2009-08-19)

Use CONVERT(DATETIME, , 120)


BO_Stuffed (BOB member since 2008-03-29)

This still gives me date as, 08/18/2009 00:00:00.
But I need only 08/18/2009.


BIDeveloper (BOB member since 2009-08-19)

Hi BIDEVELOPER,

Did you find a solution for this issue? I am facing the same issue too.

Thanks


srividya.s (BOB member since 2006-10-28)

A column of a date type ALWAYS contains also a timestamp - whether it’s 00:00:00 or any other time of a day.

If you need only date part (like 31/08/2009) then you need to convert the date into a string.


Marek Chladny :slovakia: (BOB member since 2003-11-27)

Have you applied an object format?


Mak 1 :uk: (BOB member since 2005-01-06)

Have you tried trunc(datestamp)?


Markus Lowry :us: (BOB member since 2007-03-30)