TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Get am/pm from datetime in sql query
Hiren Soni
May 24, 2012
34.8
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
Get time format of datetime in sql.
SELECT SUBSTRING(CONVERT(varchar(20), yourdate, 22), 18, 3) AS Expr1
FROM table
ORDER BY expr1 ;
SUBSTRING(CONVERT(varchar(20), yourdate, 22), 18, 3)-->it gives you a am/pm.
o/p:
----
am
pm
am
pm
Next Recommended Reading
Change System DateTime Formate Using API