FMS Home FMS Software Development Team Blog FMS Facebook Page FMS Twitter
Jump: Search:

Microsoft SQL Server ResourcesAM/PM Time format in SQL Server

Provided by Jim Ferguson, Project Manager

There are times that you need to display time in non-Military or AM/PM format.

The standard Convert formats do not have an option to return the time in this format.

 The SQL below returns only the time portion of the current date/time in the AM/PM format. You can replace the GetDate function with any datetime field to return the time portion of that field:

	SELECT substring(convert(varchar(20), GetDate(), 9), 13, 5) + ' ' + substring(convert(varchar(30), GetDate(), 9), 25, 2)


Return to the tips page


Contact Us  l   Web questions: Webmaster   l   Copyright FMS, Inc., Vienna, Virginia
Celebrating our 28th Year of Software Excellence