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
обсуждение исходный текст
Ответ на Re: subtract a day from the NOW function  ("Fernando Hevia" <fhevia@ip-tel.com.ar>)
Список pgsql-sql
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
Дата:
Сообщение: Re: subtract a day from the NOW function
Следующее
От: Michael Glaesemann
Дата:
Сообщение: Re: subtract a day from the NOW function