pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Marlowe <smarlowe@g2switchworks.com>
To: Campbell, Lance <lance@uiuc.edu>
Cc: Michael Glaesemann <grzm@seespotcode.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: subtract a day from the NOW function
Date: Thu, 07 Jun 2007 13:12:00 -0500
Message-ID: <46684A70.4080903@g2switchworks.com> (raw)
In-Reply-To: <A3AC4FA47DC0B1458C3E5396E685E63302395E27@SAB-DC1.sab.uiuc.edu>
References: <A3AC4FA47DC0B1458C3E5396E685E63302395E24@SAB-DC1.sab.uiuc.edu>
	<A3AC4FA47DC0B1458C3E5396E685E63302395E25@SAB-DC1.sab.uiuc.edu>
	<9938A77A-6E63-413D-8AC9-7CB741D075E6@seespotcode.net>
	<A3AC4FA47DC0B1458C3E5396E685E63302395E27@SAB-DC1.sab.uiuc.edu>

Campbell, Lance wrote:
> Michael,
> So based on your feedback would it be better to do option A or B below?
>
> 1) I have a timestamp field, "some_timestamp", in table "some_table".
> 2) I want to compare field "some_timestamp" to the current date - 1 day.
> I need to ignore hours, minutes and seconds.
>   
You might want to use date_trunc then:

select * from sometable where date_trunc('day',tiemstampfield) > 
date_trunc('day',now() - interval '1 day');

or something like that.



view thread (19+ messages)  latest in thread

Message-ID: <46684A70.4080903@g2switchworks.com>
Permalink:  ../46684A70.4080903@g2switchworks.com/
Also on:    postgresql.org/message-id/46684A70.4080903@g2switchworks.com

 · 

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: smarlowe@g2switchworks.com, lance@uiuc.edu, grzm@seespotcode.net
  Subject: Re: subtract a day from the NOW function
  In-Reply-To: <46684A70.4080903@g2switchworks.com>

* 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