Solved

CHANGING A DATE FORMAT IN T-SQL

Posted on 2010-11-29
6
202 Views
Last Modified: 2012-05-10
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.

0
Comment
Question by:LINNANDA
6 Comments
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 500 total points
ID: 34231910
Try this:

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

FROM yourTable

Open in new window

0
 
LVL 52

Expert Comment

by:Huseyin KAHRAMAN
ID: 34231988
"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
 
LVL 52

Expert Comment

by:Huseyin KAHRAMAN
ID: 34231999
oops, same as sammy's solution ;) ignore my post
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 7

Expert Comment

by:rmm2001
ID: 34233180
convert(smalldatetime, yourdate)
0
 

Author Closing Comment

by:LINNANDA
ID: 34238632
Thanks Sammy that worked fine.
0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 34241655
You're very welcome.

Thanks for the points/grade.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
database level memory cache..? 8 37
Are triggers slow? 7 25
SQL QUERY 3 33
Need multiple Group By's 8 28
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question