Re: Using DateDiff with Postgres - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Using DateDiff with Postgres
Date
Msg-id 003501c0ffe0$dc3e4700$1001a8c0@archonet.com
Whole thread Raw
In response to Using DateDiff with Postgres  (jeff@emojo.com (Jeff Rhys-Jones))
List pgsql-sql
From: "Jeff Rhys-Jones" <jeff@emojo.com>

> Hi there. I was wondering if anyone can tell me the correct syntax for
> using DateDiff for postgrees. I'm using MI (or mi) for minute and I
> keep getting attribute 'mi' not found.
>
> I've looked at postgres.org and can't seem to find any ref. to using
> datediff.

You just subtract dates with PG:

select now() - CURRENT_DATE;

Will return an "interval" type with the elapsed time since midnight. If you
want that in seconds do:

select extract(epoch from (now() - CURRENT_DATE));

Converting to minutes is obviously easy from there.

I think datediff() is a MS-Access thing isn't it?

- Richard Huxton




pgsql-sql by date:

Previous
From: Christof Glaser
Date:
Subject: Re: Link many attributes in one table to one attribute in another??
Next
From: "Josh Berkus"
Date:
Subject: Re: filtering