Vivek S.
Vivek S.

Reputation: 21905

How to get now() time with AM/PM in Postgresql

for example when i execute the following query

select now()::time

the result will be

"10:48:28.421"

so how to get the time with AM/PM ?? (ex. 10:48:28 AM)

NOTE : My computer's location is set to English(United States) and PostgreSQL Locale is also that

Upvotes: 1

Views: 6549

Answers (2)

Vignesh Kumar A
Vignesh Kumar A

Reputation: 28403

Try this

Select to_char(now()::Time, 'HH12:MI:SS AM')

Live Demo

Output:


TO_CHAR
05:00:12 AM

Refer Formatting Functions

Upvotes: 5

Frank Heikens
Frank Heikens

Reputation: 127086

use to_char() and the pattern you need.

Upvotes: 1

Related Questions