Article View: comp.lang.pascal.delphi.databases
Article #185Re: Date problem with SQL
From: Dan Brennand
Date: Fri, 08 Sep 2000 19:58
Date: Fri, 08 Sep 2000 19:58
85 lines
4098 bytes
4098 bytes
Keep in mind that you are building a string to pass on to the SQL
interpreter. Try this:
<original>
Add('AND date_stocker BETWEEN ''01/09/:Annee_Debut'' AND =
''31/08/:Annee_Fin''');
<new>
Add('AND date_stocker BETWEEN ''01/09/'+:Annee_Debut+''' AND
'''31/08/' + :Annee_Fin +'''');
It probably will be easier to code and understand if you use a TDate
or TDateTime variable for your parameters. There are methods to break
apart a TDate into day, month, and year; this can be a lot easier to
use, especially when going through the end of the year.
HTH,
Dan
On Fri, 8 Sep 2000 20:28:55 +0200, "Jocelyn EMANVILLE"
<floriane.emanville@freesbee.fr> wrote:
>This is a multi-part message in MIME format.
>
>------=_NextPart_000_0021_01C019D3.68B10780
>Content-Type: text/plain;
> charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
>Hello,
>i got a problem with the ParamByName function, in a query, i want that :
> Add('AND date_stocker BETWEEN ''01/09/:Annee_Debut'' AND =
>''31/08/:Annee_Fin''');
>
>in fact it would be that after the ParamByName function: (french date =
>format)
> Add('AND date_stocker BETWEEN '01/09/2000' AND '31/08/2001');
>
>But Delphi say me that it can't locate "Annee_Debut" !!! :-(
>How it can work ?
>
>------=_NextPart_000_0021_01C019D3.68B10780
>Content-Type: text/html;
> charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
><HTML><HEAD>
><META content=3D"text/html; charset=3Diso-8859-1" =
>http-equiv=3DContent-Type>
><META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
><STYLE></STYLE>
></HEAD>
><BODY bgColor=3D#ffffff>
><DIV><FONT face=3DTahoma size=3D2>Hello,</FONT></DIV>
><DIV><FONT face=3DTahoma><FONT size=3D2>i got a problem with the =
>ParamByName=20
>function, </FONT><FONT size=3D2>in a query, i want that =
>:</FONT></FONT></DIV>
><DIV><FONT face=3DTahoma size=3D2> =
> Add('AND=20
>date_stocker BETWEEN ''01/09/:Annee_Debut'' AND=20
>''31/08/:Annee_Fin''');</FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DTahoma size=3D2>in fact it would be that after the =
>ParamByName=20
>function: (french date format)</FONT></DIV>
><DIV><FONT face=3DTahoma size=3D2> =
> Add('AND=20
>date_stocker BETWEEN '01/09/2000' AND '31/08/2001');</FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DTahoma size=3D2>But Delphi say me that it can't locate =
>
>"Annee_Debut" !!! :-(</FONT></DIV>
><DIV><FONT face=3DTahoma size=3D2>How it can work =
>?</FONT></DIV></BODY></HTML>
>
>------=_NextPart_000_0021_01C019D3.68B10780--
>
--
Dan Brennand
CMDC systems, inc.
Configuration Management and Document Control: Consulting, Software,
and the only comprehesive textbook on this subject.
visit us at www.cmdcsystems.com
[SPAM block: change at to @ in my e-mail address]
Technical Details
Message-ID:
<39b942c4.1018201533@news.dimensional.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-east!supernews.com!news-feed.riddles.org.uk!nntp.cs.ubc.ca!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.he.net!pulsar.dimensional.com!dimensional.com!wormhole.dimensional.com!not-for-mailReferences:
<Ydau5.1500$a41.12360@nnrp1.none.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ffff5,a992f67cc979b78a X-Google-Attributes: gidffff5,public X-Google-Thread: f973d,a992f67cc979b78a X-Google-Attributes: gidf973d,public X-Google-Thread: f894d,a992f67cc979b78a X-Google-Attributes: gidf894d,public X-Google-ArrivalTime: 2000-09-08 13:29:28 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-east!supernews.com!news-feed.riddles.org.uk!nntp.cs.ubc.ca!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.he.net!pulsar.dimensional.com!dimensional.com!wormhole.dimensional.com!not-for-mail From: DanB@CMDCsystems.com (Dan Brennand) Newsgroups: comp.lang.pascal.delphi.databases,borland.public.delphi,alt.lang.delphi Subject: Re: Date problem with SQL Organization: CMDC systems inc. Message-ID: <39b942c4.1018201533@news.dimensional.com> References: <Ydau5.1500$a41.12360@nnrp1.none.net> X-Newsreader: Forte Free Agent 1.11/32.235 Lines: 85 Date: Fri, 08 Sep 2000 19:58:59 GMT NNTP-Posting-Host: 206.124.5.99 X-Trace: wormhole.dimensional.com 968444966 206.124.5.99 (Fri, 08 Sep 2000 14:29:26 MDT) NNTP-Posting-Date: Fri, 08 Sep 2000 14:29:26 MDT