Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Format Time

Posted on 2011-03-23
3
Medium Priority
?
591 Views
Last Modified: 2012-05-11

I have a datetime field in SQL that I need to convert to

HH:MM AM/PM

Concatenation is fine.

How?
0
Comment
Question by:cheryl9063
  • 2
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35202101
you could check out this:
select right( convert(varchar(30), yourfield, 0), 10)
0
 
LVL 1

Author Comment

by:cheryl9063
ID: 35202130
When I put getdate() in place of yourfield.. I get the below..


11  4:15PM
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 35202236
sorry:

select right( convert(varchar(30), yourfield, 0), 7)
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline

824 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