Re: One more question about intervals

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Command Prompt, Inc(dot)" <pgsql-general(at)commandprompt(dot)com>
Cc: Konstantinos Agouros <elwood(at)agouros(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: Re: One more question about intervals
Date: 2001-11-04 20:38:49
Message-ID: 9236.1004906329@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Command Prompt, Inc." <pgsql-general(at)commandprompt(dot)com> writes:
> Look into SQL92 extract() syntax, or PostgreSQL's date_part(). It's sort
> of a hack, but you could extract the days and multiply by 24, and then add
> the hours field, e.g.:
> Depending on how large your intervals got, you might have to start
> extracting week, month or year fields as well. Does anyone know a better,
> more general solution than this? Something like extract(CUMULATIVE_HOURS),
> or something? ;)

date_part('EPOCH', foo) gives the total number of seconds in an
interval. Or you can write extract(epoch from foo) if you want
to pretend this is SQL92-compatible. Unfortunately it didn't
occur to the SQL authors to provide such a function...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2001-11-04 21:09:14 Re: Libpq coding assistance
Previous Message Command Prompt, Inc. 2001-11-04 20:35:32 Re: One more question about intervals