pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Unnikrishnan Menon <unnikrishnan.menon@chennai.transys.net>
To: Josh Berkus <josh@agliodbs.com>
To: pgsql-sql@postgresql.org
Subject: Re: Date Time calculation help
Date: Tue, 22 Jan 2002 08:59:35 +0530
Message-ID: <002601c1a2f5$06ad4330$e90aa8c0@UNNIKRISHNAN> (raw)
References: <web-672382@davinci.ethosmedia.com>

Thanx Josh,

This helped solve my problem.

Unni
----- Original Message ----- 
From: "Josh Berkus" <josh@agliodbs.com>
To: "Unnikrishnan Menon" <unnikrishnan.menon@chennai.transys.net>
Sent: Tuesday, January 22, 2002 2:02 AM
Subject: Re: [SQL] Date Time calculation help


> Unni,
> 
> > I tried the same query in postgresql but the value returned is 0.
> > The query was:
> > select mod((current_date - '2002-15-01')),1);
> 
> The problem above is that you are using the DATE data type, which does
>  not admit hours.  As a result, mod(1)=0 is quite correct.
> 
> You want to use the TIMESTAMP data type, and process your outcome as an
>  interval:
> select (current_timestamp - ('2002-15-01'::Timestamp))
> which should give you some days and some hours.
> 
> See: http://techdocs.postgresql.org/techdocs/faqdatesintervals.php
> for more info about dates and times.
> 
> Of course, I could give you more help if I was clear on what exactly
>  you want to achieve.  Do you want the date, or just hours? Care to
>  elucidate?
> 
> -Josh Berkus
> 
> ______AGLIO DATABASE SOLUTIONS___________________________
>                                        Josh Berkus
>   Complete information technology      josh@agliodbs.com
>    and data management solutions       (415) 565-7293
>   for law firms, small businesses        fax 621-2533
>     and non-profit organizations.      San Francisco




view thread (3+ messages)

Message-ID: <002601c1a2f5$06ad4330$e90aa8c0@UNNIKRISHNAN>
Permalink:  ../002601c1a2f5$06ad4330$e90aa8c0@UNNIKRISHNAN/
Also on:    postgresql.org/message-id/002601c1a2f5$06ad4330$e90aa8c0@UNNIKRISHNAN

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: unnikrishnan.menon@chennai.transys.net, josh@agliodbs.com
  Subject: Re: Date Time calculation help
  In-Reply-To: <002601c1a2f5$06ad4330$e90aa8c0@UNNIKRISHNAN>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox