Solved

Format a DateTime field

Posted on 2012-04-10
5
322 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 74

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 74

Expert Comment

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

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
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
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

828 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