From: Michael Glaesemann <grzm@seespotcode.net>
To: Fernando Hevia <fhevia@ip-tel.com.ar>
Cc: pgsql-sql@postgresql.org
Subject: Re: subtract a day from the NOW function
Date: Thu, 7 Jun 2007 16:53:03 -0500
Message-ID: <7719EE57-A3BA-4301-9C94-B4FD5DBA3FCB@seespotcode.net> (raw)
In-Reply-To: <011701c7a943$d9463b30$8f01010a@iptel.com.ar>
References: <011701c7a943$d9463b30$8f01010a@iptel.com.ar>
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
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: grzm@seespotcode.net, fhevia@ip-tel.com.ar
Subject: Re: subtract a day from the NOW function
In-Reply-To: <7719EE57-A3BA-4301-9C94-B4FD5DBA3FCB@seespotcode.net>
* 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