🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.pascal.delphi.databases
2 messages
2 total messages Started by Jocelyn EMANVILLE Fri, 08 Sep 2000 18:28
Date problem with SQL
#184
Author: Jocelyn EMANVILLE
Date: Fri, 08 Sep 2000 18:28
56 lines
3326 bytes
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>&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;Add('AND=20
date_stocker BETWEEN ''01/09/:Annee_Debut'' AND=20
''31/08/:Annee_Fin''');</FONT></DIV>
<DIV>&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;Add('AND=20
date_stocker BETWEEN '01/09/2000' AND '31/08/2001');</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DTahoma size=3D2>But Delphi say me that it can't locate =

"Annee_Debut"&nbsp; !!!&nbsp; :-(</FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2>How it can work =
?</FONT></DIV></BODY></HTML>

------=_NextPart_000_0021_01C019D3.68B10780--
Re: Date problem with SQL
#185
Author: Dan Brennand
Date: Fri, 08 Sep 2000 19:58
85 lines
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>&nbsp;&nbsp;&nbsp;&nbsp; =
>&nbsp;Add('AND=20
>date_stocker BETWEEN ''01/09/:Annee_Debut'' AND=20
>''31/08/:Annee_Fin''');</FONT></DIV>
><DIV>&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp; =
>&nbsp;Add('AND=20
>date_stocker BETWEEN '01/09/2000' AND '31/08/2001');</FONT></DIV>
><DIV>&nbsp;</DIV>
><DIV><FONT face=3DTahoma size=3D2>But Delphi say me that it can't locate =
>
>"Annee_Debut"&nbsp; !!!&nbsp; :-(</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]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads