CHANGING A DATE FORMAT IN T-SQL

Hi,

i'VE A DATE  IN  YYYY-MM-DD HH:MM:SS:FF and I need to convert it to dd-mon-yyyy

so for example I need to change  2010-11-05 00:00:00.000 to 05-Nov-2010.

Any help would be much appreciated.

l.

LINNANDAAsked:
Who is Participating?
 
sammySeltzerConnect With a Mentor Commented:
Try this:

SELECT REPLACE(CONVERT(VARCHAR,yourDate ,106),' ','-')

FROM yourTable

Open in new window

0
 
HainKurtSr. System AnalystCommented:
"DATE  IN  YYYY-MM-DD HH:MM:SS:FF"

firs of all date column does not have any format ;) if you have a date column and you want to display it in "dd-mon-yyyy" use

replace(convert(varchar, datetime_column, 106),' ', '-')
0
 
HainKurtSr. System AnalystCommented:
oops, same as sammy's solution ;) ignore my post
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
rmm2001Commented:
convert(smalldatetime, yourdate)
0
 
LINNANDAAuthor Commented:
Thanks Sammy that worked fine.
0
 
sammySeltzerCommented:
You're very welcome.

Thanks for the points/grade.
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.