Solved

sql server - convert DATETIME to formated string

Posted on 2013-01-03
3
448 Views
Last Modified: 2013-01-03
Hi..
I have the following DATETIME field.   PURCHASED_DATE = 2013-01-02 09:00:00.000
I need to return the field / data in the following format

as

'Wed  Jan 2  9:00 AM'

thx
0
Comment
Question by:JElster
[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
  • 2
3 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 38739803
SELECT DATENAME(dw, GETDATE()) + ' ' + CONVERT(nvarchar(50), getdate(), 100)
0
 
LVL 31

Assisted Solution

by:James Murrell
James Murrell earned 150 total points
ID: 38739811
sorry for just a link, but this should explain everything for you

http://www.sql-server-helper.com/tips/date-formats.aspx
0
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 250 total points
ID: 38739817
If you really need a space between the time and AM/PM then you could do this:

SELECT DATENAME(dw, GETDATE()) + ' ' + replace(replace(CONVERT(nvarchar(50), getdate(), 100), 'AM', ' AM'), 'PM', ' PM')
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

628 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