Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [206.210.65.6]) by hub.org (8.8.8/8.7.5) with ESMTP id QAA27606 for ; Sat, 1 Aug 1998 16:16:38 -0400 (EDT) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id QAA18513; Sat, 1 Aug 1998 16:16:28 -0400 (EDT) To: Eric McKeown cc: pgsql-sql@hub.org Subject: Re: date versus datetime? In-reply-to: Your message of Fri, 31 Jul 1998 23:32:01 -0400 (EDT) <199808010332.XAA14257@hub.org> Date: Sat, 01 Aug 1998 16:16:28 -0400 Message-ID: <18511.902002588@sss.pgh.pa.us> From: Tom Lane Eric McKeown writes: > for instance, it seems I can do this with the date type: > select * from table where date_field < some_date_I_specify_here > However, if my reading of the manual and my experiments are correct, I > can't perform that sort of operation with the datetime type. You certainly can do that with datetime; I do it all the time. Without seeing a concrete example, I'm not sure why it's not working for you. Perhaps you are writing the comparison date in a format that's acceptable for type "date" but not for "datetime"? That doesn't seem very likely though; datetime's parser is relatively flexible. There are a couple of gotchas in writing datetime constants in SQL commands. You have to put quotes around them (they're strings as far as the parser is concerned). For example, select * from ohistory where ordertime < 'jun 10 1998 16:00'; In some situations you may have to explicitly cast the string constant to datetime type: select * from ohistory where ordertime < 'jun 10 1998 16:00'::datetime; but I find Postgres usually manages to figure out for itself that a datetime value is wanted. As far as I know those gotchas also apply to date constants, however. So I'm still confused about why one works and not the other for you. regards, tom lane