>The reason I ask is that for somereason the queries are now failing and
not
>returning any data, this is as far as I can tell, due to wrong date formats
>being put in the SQL, however, I'm assigning the parameter via .AsDateTime
>which I would have thought would work around those date inconsistancy
>returning any data, this is as far as I can tell, due to wrong date formats
>being put in the SQL, however, I'm assigning the parameter via .AsDateTime
>which I would have thought would work around those date inconsistancy
problems....
For Queries Pass the date in like so
procedure PassDateToQuery(dDate :
TDateTime);
begin
Query.ParamByName('Date').AsString:=FormatDateTime('mm/dd/yyyy',dDate);
end;
You do it as a string in the American date format which you
specify explicitly. This is because the SQL standard committee is loaded
with Americans who insist on using the 'mm/dd/yyyy' format and making the rest
of the world do the same. This way Delphi's default date format and
the default date format of the machine are irrelevent.
dDate is actualy a floating point number. If you assign
an invalid value to it that can't be translated to a date I think the
FormatDateTime function generates an exception (but I'm not quite sure - check
this out).
Nigel Tavendale
----Original Message-----Hi, got a date problem with TQueries.... I have this little bit of code:
From: Derricutt, Mark <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Date: Thursday, 4 February 1999 12:54
Subject: [DUG]: SQL/TQuery Problem...
dm.Query.ParamByName('Separator').AsString := AObject;
dm.Query.ParamByName('MeasDate').AsDateTime := StartDate;
dm.st.Lines.Text := dm.Query.Text;
dm.st.Edit;
dm.st.Edit gives me a form/memo with the contents of lines in it, which
shows:
select
S.ConfigurationID,
S.Separator,
S.Vessel,
S."Order",
C.MeasDate,
C.BrineFlow,
C.SteamFlow,
C.MassFlow,
C.Enthalpy,
C.Pressure,
C.Temperature
from
Separator S, CalcData C
where
S.Vessel = C.Object AND
S.Separator = ? AND
C.MeasDate = ?
The ?'s in the last two lines WERE :Separator and :MeasDate respectively, is
it natural for them to be represented as ?'s???? Or is this what is
actually getting passed to the query...
The reason I ask is that for somereason the queries are now failing and not
returning any data, this is as far as I can tell, due to wrong date formats
being put in the SQL, however, I'm assigning the parameter via .AsDateTime
which I would have thought would work around those date inconsistancy
problems....
Any thoughts/ideas/suggestions or darn it - out-right solutions?
Mark
--
Mark Derricutt, Software Engineer
PB Power (NZ) Ltd