Hourly dates - Mailing list pgsql-general

From Andrew Maclean
Subject Hourly dates
Date
Msg-id e7ddbec60906221654y44cd6e65ja0a9997e5c89ac38@mail.gmail.com
Whole thread Raw
Responses Re: Hourly dates
List pgsql-general
Is this the best way of getting a table of hourly dates?

-- How to generate a table of dates at hourly intervals between two dates.

-- select timestamp 'epoch' + generate_series * interval '1 second' as
dates from generate_series(extract(epoch from date_trunc('hour',
timestamp '2001-02-16 20:38:40'))::bigint,extract(epoch from
date_trunc('hour', timestamp '2001-02-17 20:38:40'))::bigint, 3600)
select generate_series * interval '1 second' +  date_trunc('hour',
timestamp '2001-02-16 20:38:40') as dates
  from generate_series(0,extract(epoch from(date_trunc('hour',
timestamp '2001-02-17 20:38:40') - date_trunc('hour', timestamp
'2001-02-16 20:38:40')))::bigint, 3600)

The commented out query seems to take into account the timezone which
is not what I want.

Andrew


--
___________________________________________
Andrew J. P. Maclean
Centre for Autonomous Systems
The Rose Street Building J04
The University of Sydney  2006  NSW
AUSTRALIA
Ph: +61 2 9351 3283
Fax: +61 2 9351 7474
URL: http://www.acfr.usyd.edu.au/
___________________________________________

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Inserting Values into Interval
Next
From: Greg Smith
Date:
Subject: Re: Replication