Solved

Format a DateTime field

Posted on 2012-04-10
5
321 Views
Last Modified: 2012-04-10
Hi Guys,

Can somebody help me to format a Datetime field "Eventdate"  in my SQL query to this format:

24 Jul 2012

This is the query:

"SELECT EventDate, EventDescription FROM Events"
0
Comment
Question by:dizzycat
5 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 37828992
CONVERT(VARCHAR(11), eventdate, 106)
0
 
LVL 14

Accepted Solution

by:
nishant joshi earned 500 total points
ID: 37829005
IF eventdate is datetime then

SELECT CONVERT(VARCHAR(11),EventDate,106) AS [DD MON YYYY]  EventDescription FROM Events
0
 
LVL 23

Expert Comment

by:wdosanjos
ID: 37829007
SELECT convert(varchar(20),EventDate,106) as EventDate, EventDescription FROM Events

Other date/time formatting options here:
http://msdn.microsoft.com/en-us/library/ms187928%28v=sql.100%29.aspx
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37829016
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 37829168
wouldn't a split be in order?
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

813 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now