Re: subtract a day from the NOW function

From: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>
To: "'Michael Glaesemann'" <grzm(at)seespotcode(dot)net>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: subtract a day from the NOW function
Date: 2007-06-07 20:38:47
Message-ID: 011701c7a943$d9463b30$8f01010a@iptel.com.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql


>> B) SELECT * FROM some_table WHERE to_char(some_timestamp,
>> 'YYYYMMDD') >
>> to_char((now() - interval '1 day'), 'YYYYMMDD');
>
>I'd never use to_char to compare dates. The built-in comparison
>operators work just fine.
>

Why not? I'm curious if has anything to do with performance or just style?
Any difference between:
... WHERE to_char(my_date_col:date, 'YYYY.MM.DD') < '2007.06.07'
and
... WHERE my_date_col:date < '2007.06.07'

Is there a 3rd better way to do this comparison?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2007-06-07 20:48:22 Re: Suppress checking of chmod 700 on data-dir?
Previous Message Oliver Elphick 2007-06-07 20:38:41 Re: Suppress checking of chmod 700 on data-dir?

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Crawford 2007-06-07 21:07:33 Re: subtract a day from the NOW function
Previous Message Michael Glaesemann 2007-06-07 19:22:44 Re: subtract a day from the NOW function