Re: Days betwen dates

From: Andy Holman <info(at)i-developit(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Days betwen dates
Date: 2001-01-09 23:27:01
Message-ID: 3A5B9E45.95A8A84C@i-developit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Actually I found a fix for this (kinda)
There is a function named date_part. And
you can use something like

SELECT date_part('epoch', age('2001-01-24')) / 60 / 60 /24;

I believe that was what I used, and that gives you the days.
I am working from memory at the moment, but that is close.

--Andy

Stuart Urban wrote:
>
> I do not know if Postgres has the TO_DAYS() function, but I use that one
> in MySQL. Try something like TO_DAYS(dateone) - TO_DAYS(now()); [don't
> know if the syntax is correct, but you can probably figure it out if you
> see whether the TO_DAYS() function exists].
>
> --Stu
>
> On Tue, 9 Jan 2001, Andy Holman
> wrote:
>
> > Anyone know how I can just get the number of
> > days between dates in 2 columns in a query?
> >
> > I am using something like age('dateone', 'now')
> > currently but that returns 1 year 10 mons 14 12:53:10
> > or something of the like. I just want the days between
> > them. I am using php. Please let me know if you have
> > any ideas.
> >
> > Thanks,
> > Andy
> >

Browse pgsql-novice by date

  From Date Subject
Next Message Sandeep Joshi 2001-01-10 02:10:13 delete trigger function in 'C'
Previous Message Robert B. Easter 2001-01-09 21:29:51 Re: Comparison Operator problem