Skip to main content

All Questions

Filter by
Sorted by
Tagged with
18 votes
1 answer
45k views

How do I generate a date series in PostgreSQL?

If you're looking to generate a time series, see this question Let's say that I want to generate a series of dates between two dates. I see the function generate_series provides only Function ...
Evan Carroll's user avatar
  • 64.7k
3 votes
1 answer
10k views

How to query dates in different timezones?

I have a table and index in a PostgreSQL 10.18 database: CREATE TABLE some_table ( expires_at timestamptz ); CREATE INDEX ON some_table(expires_at); Is there a way to write this query in a way to ...
ffox003's user avatar
  • 185
1 vote
1 answer
6k views

Converting UTC time to timestamptz always adds the +01 offset in Postgres

In Postgres 9.5, I do the following to convert a timestamptz to the UTC timezone: SELECT TIMESTAMP WITH TIME ZONE '2016-02-20 15:15:54.000495+01' AT TIME ZONE 'UTC' this outputs correctly 2016-02-20 ...
NumberFour's user avatar
1 vote
1 answer
2k views

Format timezone to +-#### instead of +-##

I am curious if there is a way to configure Postgres (9.1+) to format the TZ part of a "timestamp with time zone" as +-####, just like PHP's date.format method does using "O". PHP Docs: O | ...
Radu Maris's user avatar
1 vote
1 answer
2k views

Update record with converted epoch timestamp from another column

I'm trying to convert epoch data in one column (timestamp_epoch) to a legitimate timestamp in another column (timestamp) for every record in a table. In reading the PostgreSQL Documentation it ...
jbush's user avatar
  • 13
0 votes
1 answer
1k views

Filter column by records matching a timezone in Postgres

I want to check whether any rows in my column (TIMESTAMP WITH TIME ZONE) are not stored using UTC. Is there a query I can write to match values that are stored with a TZ offset of 1 or 8 or 11 or (not ...
Kevin Burke's user avatar
0 votes
1 answer
2k views

Postgres changing data type from timestamp to timestamptz (with time zone)

I recognize there are some similar questions, and I've read quite a few, so pardon me if I just missed the answer. I have data that was stored as a TIMESTAMP data type, but now we want it to be stored ...
codki's user avatar
  • 11