PDA

View Full Version : Date arithmetic issues....


Feanor
01-07-02, 04:40
I'm trying to return date parts from a SQL-derived date string.... the SQL for the date-difference:

SELECT now() - min(start_raw) AS diff FROM event_view WHERE appointment_id=1175 produces: '1 day 19:06'

Now, I want to take date/time parts from this string BUT I want to do something like: date_part('day', INTERVAL (SELECT now() - min(start_raw) AS diff FROM event_view WHERE appointment_id=1175)); or some such thing. However, I keep getting errors no matter how I try to cast this, quote it, etc.

Anyone else deal with such issues?

eperich
01-31-02, 07:14
There are some functions in the postgresql db itself.

There is a good FAQ:

DATE-TIME FAQ (http://techdocs.postgresql.org/techdocs/faqdatesintervals.php)

Or try the datecalc module from Perl
you can find this under CPAN

Eperich