Thom Brown <thom(at)linux(dot)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