Skip to content
Advertisement

Select timestamp with time zone, but ignore seconds

I’m selecting a timestamptz from a PosgreSQL database.

I want my SELECT to return only the date, hours and minutes. No seconds. Can I set the date format in my psql SELECT to accommodate this?

Advertisement

Answer

You can use date_trunc() to truncate seconds and still return a timestamptz:

Or you can use to_char() to return a formatted timestamp as text any way you like:

Note that this will format the timestamptz according to your current time zone setting. Details:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement