Re: subtract a day from the NOW function

Поиск
Список
Период
Сортировка
Искать
От
Michael Glaesemann
Тема
Re: subtract a day from the NOW function
Дата
Msg-id
7719EE57-A3BA-4301-9C94-B4FD5DBA3FCB@seespotcode.net
Ответ на
Список
Дерево обсуждения
subtract a day from the NOW function "Campbell, Lance" <lance@uiuc.edu>
Re: subtract a day from the NOW function Osvaldo Kussama <osvaldo_kussama@yahoo.com.br>
Re: subtract a day from the NOW function "Campbell, Lance" <lance@uiuc.edu>
Re: subtract a day from the NOW function "Campbell, Lance" <lance@uiuc.edu>
Re: subtract a day from the NOW function Michael Glaesemann <grzm@seespotcode.net>
Re: subtract a day from the NOW function "Campbell, Lance" <lance@uiuc.edu>
Re: subtract a day from the NOW function Scott Marlowe <smarlowe@g2switchworks.com>
Re: subtract a day from the NOW function Steve Crawford <scrawford@pinpointresearch.com>
Re: subtract a day from the NOW function Michael Glaesemann <grzm@seespotcode.net>
Re: subtract a day from the NOW function Steve Crawford <scrawford@pinpointresearch.com>
Re: subtract a day from the NOW function Tom Lane <tgl@sss.pgh.pa.us>
Re: subtract a day from the NOW function Michael Glaesemann <grzm@seespotcode.net>
Re: subtract a day from the NOW function Michael Glaesemann <grzm@seespotcode.net>
Re: subtract a day from the NOW function "Fernando Hevia" <fhevia@ip-tel.com.ar>
Re: subtract a day from the NOW function Michael Glaesemann <grzm@seespotcode.net>
Re: subtract a day from the NOW function "Campbell, Lance" <lance@uiuc.edu>

On Jun 7, 2007, at 15:38 , Fernando Hevia wrote:

> Why not? I'm curious if has anything to do with performance or just  
> style?

Not style. Maybe performance because there's fewer function calls,  
but primarily correctness. By using to_char you no longer have a date— 
you have a text value—and are relying on the collocation of your  
database to compare two text values. This can lead to subtle bugs in  
your code. Similarly, I would never use to_char to compare two integers:

SELECT 20 > 9 AS int_values    , to_char(20, '9') > to_char(9, '9') AS text_values;

Is this what you would expect? What's the advantage to using to_char?

Michael Glaesemann
grzm seespotcode net



В списке pgsql-sql по дате отправления
От: Osvaldo Kussama
Дата:
От: Michael Glaesemann
Дата:
FAQ