Date / interval question

From: kevin kempter <kevin(at)kevinkempterllc(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Date / interval question
Date: 2008-04-11 03:26:14
Message-ID: AAD89495-0184-42F0-9ABB-DB2C2E26D429@kevinkempterllc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi List;

I'm populating a time dimension. I need to get the number of days
since the start of the fiscal year and also the number of months since
the start of the fiscal year based on the current 'date' being
processed.

Example:

my current process date is 01/01/2007
start date of fiscal year is 09/01/2006

I can get the number of days since the start of the fiscal year like
this:

# select date '01/01/2007' - date '09/01/2006' as interval;
interval
----------
122
(1 row)

However I'm stumped [er how to get the number of months from
09/01/2007 thru 01/01/2007

Thoughts ?

Thanks in advance...

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2008-04-11 05:02:44 Re: Date / interval question
Previous Message Andrew Falanga 2008-04-11 03:09:07 Re: How does psql actually implement the \d commands