DateTime field

R

Ryan Langton

Are there any functions to retrieve only the Date from a DateTime field?

Thanks,
Ryan
 
S

Sylvain Lafontaine

Not sure, but I think that you must extract it in its character format;
something like:

convert (nvarchar (10), MyDateTimeField, 102)

Of course, you can also add a level of conversion to get it back in DateTime
format:

convert (DateTime, convert (DateTime, MyDateTimeField, 102), 102)
Or:
convert (DateTime, convert (DateTime, MyDateTimeField, 102) + '
12:00:00 AM', 102)


There is also the function DatePart (....).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top