[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Converting Dates with SQL

Posted on 2013-01-07
Medium Priority
Last Modified: 2013-01-24
I know I've done this before but can't remember

How do I convert a date so it comes out in long day, month year format in t-sql

for example



Monday, January 7, 2013
Question by:johnnyg123
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
LVL 17

Expert Comment

by:Kent Dyer
ID: 38752380
CAST / CONVERT in BOL should cover this..



LVL 23

Accepted Solution

Steve Wales earned 2000 total points
ID: 38752418
Cast/Convert don't seem to translate the date format into words.

You need the DATENAME function to do that.

Here's a (somewhat ugly) way to handle it but shows how to extract the words from a datetime parameter:

select datename(dw,getdate())+', '+
       datename(mm,getdate())+' '+
       rtrim(convert(char,datepart(dd,getdate())))+', '+
       rtrim(convert(char,datepart(yyyy, getdate())))

Monday, January 7, 2013

Open in new window

DATEPART: http://msdn.microsoft.com/en-us/library/ms174420.aspx
DATENAME: http://msdn.microsoft.com/en-us/library/ms174395.aspx

Expert Comment

ID: 38752462
take a look, contains all conversions

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

LVL 21

Expert Comment

by:Alpesh Patel
ID: 38753587
select Format (sysdatetime(), 'D', 'en-US')
LVL 37

Expert Comment

ID: 38753626
PatelAlpesh, the FORMAT function only exists in SQL Server 2012.  The question clearly states that the asker uses SQL Server 2008.  Please read the full question and other posts before deciding to post yourself. (this is not the first time)

The answer by sjwales achieves what has been asked.
LVL 75

Expert Comment

by:Anthony Perkins
ID: 38761568
this is not the first time
And unfortunately it will not be the last, despite repeated reminder over the years.

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

656 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