comparing dates with timestamps ?

Started by raptor@tvskat.netabout 21 years ago3 messagesgeneral
Jump to latest
#1raptor@tvskat.net
raptor@tvskat.net

how to compare dates with timestamp..if i dont care about
the hour:minute part of the timestamp... i.e. i want
to be able to do exact match :

timestamp in (select date from table where .....)

tia

#2Mike Rylander
mrylander@gmail.com
In reply to: raptor@tvskat.net (#1)
Re: comparing dates with timestamps ?

On Sun, 13 Feb 2005 18:57:30 +0200, raptor <raptor@tvskat.net> wrote:

how to compare dates with timestamp..if i dont care about
the hour:minute part of the timestamp... i.e. i want
to be able to do exact match :

timestamp in (select date from table where .....)

timestamp::DATE in ((select date from table where...))

--
Mike Rylander
mrylander@gmail.com
GPLS -- PINES Development
Database Developer
http://open-ils.org

#3Robby Russell
robby@planetargon.com
In reply to: raptor@tvskat.net (#1)
Re: comparing dates with timestamps ?

On Sun, 2005-02-13 at 18:57 +0200, raptor wrote:

how to compare dates with timestamp..if i dont care about
the hour:minute part of the timestamp... i.e. i want
to be able to do exact match :

timestamp in (select date from table where .....)

Try something like this: (created is a timestamp data type)

SELECT created::date FROM orders.payment WHERE id = 100;
created
------------
2004-11-28

or

SELECT id, email FROM orders.payment WHERE created::date = now()::date;

-Robby

--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | robby@planetargon.com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now hosting Ruby on Rails Apps ---
****************************************/