Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CHANGING A DATE FORMAT IN T-SQL

Posted on 2010-11-29
6
Medium Priority
?
205 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 2000 total points
ID: 34231910
Try this:

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

FROM yourTable

Open in new window

0
 
LVL 60

Expert Comment

by:HainKurt
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 60

Expert Comment

by:HainKurt
ID: 34231999
oops, same as sammy's solution ;) ignore my post
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
In this article I will describe the Detach & Attach 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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

636 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