🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.vdbase.data.sql
Article #1369

Re: BETWEEN and DATE filter

#1369
From: Steve Koterski
Date: Thu, 12 Feb 1998 00:00
51 lines
2753 bytes
On Thu, 12 Feb 1998 17:53:19 +0100, Andrea Starz <starzand@mbox.vol.it>
wrote:

>Ken Mayer wrote:
>> 
>> Andrea Starz wrote:
>> > N.B.: Date are in format dd/mm/yy, is important?
>> 
>> Yes. Try MM/DD/YYYY to be sure ... (although MM/DD/YY should work).
>
>Ok modified, not work and same error.
>
>Another idea?

Please post the SQL statement you are *now* using and that is failing.

As Ken intimated in another reply, date literals in SQL statements must be
enclosed in quotation marks. This is to differentiate date literals from
arithmetic calculations. For instance, "12/30/1998" is December 30th, 1998,
while 12/30/1998 is twelve divided by thirty divided by 1,998.

Because date literals are enclosed in quotation marks, they are technically
string literals in local SQL statements. It is only by way of the context
they are used in the statement that the local SQL parser treats the literal
as a date rather than a string value.

To help you find where the problem causing your error is occurring,
temporarily drop the WHERE clause and run the query. If the error no longer
occurs, you will have determined that the problem is in the WHERE clause.
If the problem still occurs, the problem is elsewhere in the statement.

If the problem is in the WHERE clause, the first diagnostic to perform is
to double-check the data type of the DATA_AGG column in the table. Is it a
DATE or CHAR column?

As an experiment, you can force the SQL statement to treat this column as a
DATE column -- no matter what its actual data type is. Do this by applying
the CAST function to the column. For example:

  SELECT OL_AGG, COUNT(DISTINCT COM_AGG)
  FROM "C:\APPL\ACOL\aggiorna.dbf"
  WHERE (CAST(DATA_AGG AS DATE) BETWEEN "01/12/97" AND "12/31/97")
  GROUP BY OL_AGG
  ORDER BY OL_AGG

**************************************************************************
Steve Koterski
Borland International, Inc.
http://www.borland.com/delphi
(Remove the "SPICEDHAM2" from the address. Death to spam-bots!)
Technical Details
Message-ID: <34e45da6.12774006@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34E18B86.6F7A@mbox.vol.it> <34e5ee29.8053776@forums.borland.com> <34E31E68.C15@mbox.vol.it> <34E3247B.3FCE@borland.com> <34E328FF.28E6@mbox.vol.it>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: ff5a1,4441f152cccd222a
X-Google-Attributes: gidff5a1,public
From: koterski@SPICEDHAM2borland.com (Steve Koterski)
Subject: Re: BETWEEN and DATE filter
Date: 1998/02/12
Message-ID: <34e45da6.12774006@forums.borland.com>
X-Deja-AN: 324539366
Content-Transfer-Encoding: 7bit
References: <34E18B86.6F7A@mbox.vol.it> <34e5ee29.8053776@forums.borland.com> <34E31E68.C15@mbox.vol.it> <34E3247B.3FCE@borland.com> <34E328FF.28E6@mbox.vol.it>
Mime-Version: 1.0
Reply-To: koterski@SPICEDHAM2borland.com
Content-Type: text/plain; charset=us-ascii
Organization: Borland International, Technical Publications
Newsgroups: borland.public.vdbase.data.sql