Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: Aliases for "timestamp with time zone" and "at time zone"

I happen to have tables with timestamp without time zone column in my database. Now I need to compare them with respect to time zone.

I can do it like:

select my_timestamp::timestamp with time zone at time zone 'EST5EDT'
from my_table
where 
    my_timestamp >= '2010-07-01'::timestamp at time zone 'EST5EDT' 
    and my_timestamp < '2010-08-01'::timestamp at time zone 'EST5EDT'

This is getting pretty ugly. Is there a shorter way that does not require me to type timestamp with time zone as type and at time zone as conversion?

like image 808
Konrad Garus Avatar asked Jan 25 '26 21:01

Konrad Garus


1 Answers

timestamptz is an alias for timestamp with time zone, timestamp is an alias for timestamp without time zone.

I don't think at time zone has an alias.

like image 132
Milen A. Radev Avatar answered Jan 27 '26 13:01

Milen A. Radev