Skip site navigation (1) Skip section navigation (2)

generate_series() Interpretation

From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: generate_series() Interpretation
Date: 2011-06-27 17:49:09
Message-ID: AC9381D0-1004-41CF-85E8-8F947565BA7D@kineticode.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hackers,

I'm curious about behavior such as this:

bric=# select generate_series('2011-05-31'::timestamp , '2012-04-01'::timestamp, '1 month');
   generate_series   
---------------------
 2011-05-31 00:00:00
 2011-06-30 00:00:00
 2011-07-30 00:00:00
 2011-08-30 00:00:00
 2011-09-30 00:00:00
 2011-10-30 00:00:00
 2011-11-30 00:00:00
 2011-12-30 00:00:00
 2012-01-30 00:00:00
 2012-02-29 00:00:00
 2012-03-29 00:00:00

It seems to me that this is subject to interpretation. If I was building a calendaring app, for example, I might rather that the results were:

   generate_series   
---------------------
 2011-05-31 00:00:00
 2011-06-30 00:00:00
 2011-07-31 00:00:00
 2011-08-31 00:00:00
 2011-09-30 00:00:00
 2011-10-31 00:00:00
 2011-11-30 00:00:00
 2011-12-31 00:00:00
 2012-01-31 00:00:00
 2012-02-29 00:00:00
 2012-03-31 00:00:00

Is there some way to change the interpretation of interval calculation like this? Or would I just have to write my own function to do it the way I want?

Thanks,

David


Responses

pgsql-hackers by date

Next:From: Josh BerkusDate: 2011-06-27 17:51:07
Subject: Re: beta3?
Previous:From: Bruce MomjianDate: 2011-06-27 17:49:04
Subject: Re: pg_upgrade defaulting to port 25432

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group