Solved

CHANGING A DATE FORMAT IN T-SQL

Posted on 2010-11-29
6
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 29

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 55

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 55

Expert Comment

by:Huseyin KAHRAMAN
ID: 34231999
oops, same as sammy's solution ;) ignore my post
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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 29

Expert Comment

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

Thanks for the points/grade.
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

688 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