Received: from mta02-svc.ntlworld.com (mta02-svc.ntlworld.com [62.253.162.42]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0FCeDV49516 for ; Tue, 15 Jan 2002 07:40:13 -0500 (EST) (envelope-from boylesa@roselink.co.uk) Received: from dualtower ([213.105.88.197]) by mta02-svc.ntlworld.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with SMTP id <20020115124015.BKBM8848.mta02-svc.ntlworld.com@dualtower>; Tue, 15 Jan 2002 12:40:15 +0000 Message-ID: <00eb01c19dc1$b6bea180$c55869d5@dualtower> From: "Steve Boyle \(Roselink\)" To: "Unnikrishnan Menon" , References: <005e01c19d79$16219db0$e90aa8c0@UNNIKRISHNAN> Subject: Re: Date Time calculation help Date: Tue, 15 Jan 2002 12:39:46 -0000 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00E8_01C19DC1.B69D36D0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200201/164 X-Sequence-Number: 6250 This is a multi-part message in MIME format. ------=_NextPart_000_00E8_01C19DC1.B69D36D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Unnikrishanan, The following query will return the number of whole days between the two da= tes (a working version of postgres query you posted). select date_part('day','now'::datetime - '2001-01-15'::datetime); Other available datetime functions can be found at: http://www.il.postgresql.org/users-lounge/docs/7.1/postgres/functions-datet= ime.html hih steve boyle ----- Original Message -----=20 From: Unnikrishnan Menon=20 To: pgsql-sql@postgresql.org=20 Sent: Monday, January 14, 2002 2:58 PM Subject: [SQL] Date Time calculation help Hi, I have a particular query in Oracle : select mod((sysdate - to_date('15-JAN-02','dd-mon-yy')),1) from dual; The above query gives 0.752.. as the difference between the two days whic= h when multiplied by 24 gives around 3.1.. hrs.=20 I tried the same query in postgresql but the value returned is 0. The query was: select mod((current_date - '2002-15-01')),1); I require the difference in time to the last second to be shown as time l= eft. Could anyone suggest as to how to overcome this particular problem. Thanx in advance, Unni ------=_NextPart_000_00E8_01C19DC1.B69D36D0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Unnikrishanan,
 
The following query will return the number= of whole=20 days between the two dates (a working version of postgres query you=20 posted).
 
select date_part('day','now'::datetime -= =20 '2001-01-15'::datetime);
Other available datetime functions can be = found=20 at:
http://www.il.postgresql.org/users-lounge/docs/7.1/postgr= es/functions-datetime.html
 
hih
 
steve boyle
----- Original Message -----
Fro= m:=20 Unnikrishnan Menon
To: pgsql-sql@postgresql.org
Sent: Monday, January 14, 2002 2:5= 8=20 PM
Subject: [SQL] Date Time calculati= on=20 help

Hi,
 
I have a particular query in Oracle=20 :
 
select mod((sysdate -=20 to_date('15-JAN-02','dd-mon-yy')),1) from dual;
The above query gives 0.752.. as the dif= ference=20 between the two days which when multiplied by 24 gives around 3.1.. hrs.= =20
 
I tried the same query in postgresql but= the=20 value returned is 0.
The query was:
select mod((= current_date=20 - '2002-15-01')),1);
 
I require the difference in time to the = last=20 second to be shown as time left. Could anyone suggest as to how to overco= me=20 this particular problem.
 
Thanx in advance,
 
Unni
------=_NextPart_000_00E8_01C19DC1.B69D36D0--