pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Jeff Rhys-Jones <jeff@emojo.com>
To: pgsql-sql@postgresql.org
Subject: Re: Using DateDiff with Postgres
Date: Thu, 28 Jun 2001 15:44:38 +0100
Message-ID: <003501c0ffe0$dc3e4700$1001a8c0@archonet.com> (raw)
References: <7a92561a.0106280301.6972d149@posting.google.com>

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





view thread (3+ messages)  latest in thread

Message-ID: <003501c0ffe0$dc3e4700$1001a8c0@archonet.com>
Permalink:  ../003501c0ffe0$dc3e4700$1001a8c0@archonet.com/
Also on:    postgresql.org/message-id/003501c0ffe0$dc3e4700$1001a8c0@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, jeff@emojo.com
  Subject: Re: Using DateDiff with Postgres
  In-Reply-To: <003501c0ffe0$dc3e4700$1001a8c0@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox