Re: One more question about intervals - Mailing list pgsql-general

From Tom Lane
Subject Re: One more question about intervals
Date
Msg-id 9236.1004906329@sss.pgh.pa.us
Whole thread Raw
In response to Re: One more question about intervals  ("Command Prompt, Inc." <pgsql-general@commandprompt.com>)
List pgsql-general
"Command Prompt, Inc." <pgsql-general@commandprompt.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

pgsql-general by date:

Previous
From: "Command Prompt, Inc."
Date:
Subject: Re: One more question about intervals
Next
From: "Jeff Lu"
Date:
Subject: Is there an internal timestamp on a table when it was created?