Re: Determining period between 2 dates - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: Determining period between 2 dates
Date
Msg-id 4D5BA8A0020000250003AB17@gw.wicourts.gov
Whole thread Raw
In response to Re: Determining period between 2 dates  (Thom Brown <thom@linux.com>)
List pgsql-hackers
Thom Brown <thom@linux.com> wrote:
> For the number of fortnights, that becomes:
> 
> select extract(epoch from now() - '2010-01-01 
> 11:45:13'::timestamp)/60/60/24/14;
> 
> You'd think with PostgreSQL having such a rich type system, it
> wouldn't need to come to that.  It's just asking for the number of
> intervals between 2 timestamps rather than the number of seconds
> and dividing it to the point you get your answer.
The SQL standard has syntax to support getting that in YEAR, MONTH,
DAY, HOUR, MINUTE, or SECOND (with the ability to specify decimal
positions for SECOND).  Nothing in there about fortnights, however.
<left paren> <datetime value expression> <minus sign><datetime term> <right paren> <interval qualifier>
I seem to remember previous discussions where people have resisted
implementing this part of the standard, although I can't remember
the reason.  I'll probably be reminded soon...  :-)
-Kevin


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Sync Rep for 2011CF1
Next
From: Marti Raudsepp
Date:
Subject: Re: Determining period between 2 dates