Solved

append AM or PM

Posted on 2003-12-08
3
468 Views
Last Modified: 2008-03-06
I'm building a field that holds a TIME value by:
.
.
.
  DATENAME(hh, wDate) + ':' + DATENAME(mi, wDate) as myTime,
.
.

I'd like to add an 'am' or 'pm' to the string but don't see that as an option for either DATENAME or DATEPART
0
Comment
Question by:juststeve
3 Comments
 
LVL 48

Assisted Solution

by:Mikal613
Mikal613 earned 100 total points
Comment Utility
SELECT  
(SUBSTRING(CONVERT(VARCHAR(30), GETDATE(), 109), 13, 8) +
SUBSTRING(CONVERT(VARCHAR(30), GETDATE(), 109), 25, 2)) AS myTimeHHMISS
0
 
LVL 26

Assisted Solution

by:Hilaire
Hilaire earned 150 total points
Comment Utility
DATENAME(hh, wDate) + ':' + DATENAME(mi, wDate) + case when datepart(hh, wDate) > 12 then ' PM' else ' AM' end as myTime,


Hilaire
0
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 250 total points
Comment Utility
It looks as if "wDate" is a datetime/smalldatetime data type; if so:

SELECT RIGHT(CONVERT(VARCHAR(24), wDate, 0), 7)
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

763 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