Re: DateDiff in PostgreSQL

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: "George A(dot)J" <jinujosein(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: DateDiff in PostgreSQL
Date: 2003-11-07 13:47:25
Message-ID: 3FABA26D.5030900@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dnia 2003-11-07 14:34, Użytkownik George A.J napisał:
> Hi,
>
> i am converting a MSSQL Server database to PostgreSQL.
>
> Using PostgreSQL version 7.3.2.
>
> Is there any function like the DateDiff() in MSSQL Server.
>
> ie, a function that returns difference of two dates(timestamp) in days
> or months or year..
>
> The - operator for timestamp retuns the intervel in days only.

1. You can convert timestamps to dates and then substract them. The
result will be days::integer.

2. Interval result is not a problem - you can extract epoch from it. The
result is seconds::integer - do whatever you want with it.

Regards,
Tomasz Myrta

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Christopher Browne 2003-11-07 13:47:45 Re: SQL to PLC to diverter gate, can this be done?
Previous Message Yasir Malik 2003-11-07 13:45:16 Re: DateDiff in PostgreSQL