Re: [SQL] function to find difference between in days between two dates

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Ashish Karalkar" <ashish(dot)karalkar(at)info-spectrum(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] function to find difference between in days between two dates
Date: 2007-06-14 07:00:12
Message-ID: 162867790706140000w478d4bds4a0a2f42a8666a26@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Hello

PostgreSQL hasn't any official function for it. If you need it, you
can write own function

CREATE FUNCTION date_diff(date, date) returns integer as $$
select $1-$2; $$ language sql;

Regards
Pavel Stehule

2007/6/14, Ashish Karalkar <ashish(dot)karalkar(at)info-spectrum(dot)com>:
>
>
> Hello all,
>
> Is there any function to find differences in days between two dates?
>
>
> I am using
>
> select abs(current_date - '2007-06-15')
>
> to get the desired result.
> but I think there must be a function and I am missing it,
> if so, can anybody please point me to that.
>
>
> Thanks in advance
>
> With regards
> Ashish Karalkar
>
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2007-06-14 07:02:46 Re: function to find difference between in days between two dates
Previous Message Ashish Karalkar 2007-06-14 06:26:15 function to find difference between in days between two dates

Browse pgsql-sql by date

  From Date Subject
Next Message A. Kretschmer 2007-06-14 07:02:46 Re: function to find difference between in days between two dates
Previous Message Ashish Karalkar 2007-06-14 06:26:15 function to find difference between in days between two dates