Thread: Date interval

Date interval

From
"Richard Sydney-Smith"
Date:
I am looking for a way to convert an interval into a number of days ( integer);
 
In sybase I would use :
 
days(today()-r_expire)
 
where r_expire is the timestamp I am comparing against.
 
How do we do this in postgres?
 
date_trunc(today()-r_expire) does not seem to do it
 
thanks
 
Richard
 

Re: Date interval

From
Tomasz Myrta
Date:
> I am looking for a way to convert an interval into a number of days ( 
> integer);
>  
> In sybase I would use :
>  
> days(today()-r_expire)
>  
> where r_expire is the timestamp I am comparing against.
>  
> How do we do this in postgres?
>  
> date_trunc(today()-r_expire) does not seem to do it

select extract(epoch from some_interval)/3600/24::integer

Regards,
Tomasz Myrta



Re: Date interval

From
sad
Date:
On Friday 26 September 2003 09:18, you wrote:
> I am looking for a way to convert an interval into a number of days (
> integer);
>
> In sybase I would use :
>
> days(today()-r_expire)

SELECT  now()::DATE - '1900-12-10'::DATE;
           ?column?
--------------------------------37545


SELECT  now()-'1900-12-10'::timestamp;
           ?column?
--------------------------------37545 days 06:10:54.2021608353