Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id BC4609FB73D for ; Thu, 7 Jun 2007 18:53:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 65734-01 for ; Thu, 7 Jun 2007 18:53:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mtao01.charter.net (mtao01.charter.net [209.225.8.186]) by postgresql.org (Postfix) with ESMTP id BEE229FB72B for ; Thu, 7 Jun 2007 18:53:06 -0300 (ADT) Received: from aa07.charter.net ([10.20.200.159]) by mtao01.charter.net (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20070607215304.VLJE1482.mtao01.charter.net@aa07.charter.net>; Thu, 7 Jun 2007 17:53:04 -0400 Received: from [10.0.1.3] (really [66.188.164.45]) by aa07.charter.net with ESMTP id <20070607215304.MULV8059.aa07.charter.net@[10.0.1.3]>; Thu, 7 Jun 2007 17:53:04 -0400 In-Reply-To: <011701c7a943$d9463b30$8f01010a@iptel.com.ar> References: <011701c7a943$d9463b30$8f01010a@iptel.com.ar> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed Message-Id: <7719EE57-A3BA-4301-9C94-B4FD5DBA3FCB@seespotcode.net> Cc: Content-Transfer-Encoding: quoted-printable From: Michael Glaesemann Subject: Re: subtract a day from the NOW function Date: Thu, 7 Jun 2007 16:53:03 -0500 To: "Fernando Hevia" X-Mailer: Apple Mail (2.752.2) X-Chzlrs: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/70 X-Sequence-Number: 28560 On Jun 7, 2007, at 15:38 , Fernando Hevia wrote: > Why not? I'm curious if has anything to do with performance or just =20= > style? Not style. Maybe performance because there's fewer function calls, =20 but primarily correctness. By using to_char you no longer have a date=97=20= you have a text value=97and are relying on the collocation of your =20 database to compare two text values. This can lead to subtle bugs in =20 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