Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread SQL TimeStamp
Thu, Oct 19 2006 9:25 AMPermanent Link

"Sean M. McDermott"
Hi anyone, I am trying to query a table based on a timestamp field but it
can't parse it. Error says... "Expected column name but found "12/5/2005
11:23 PM"

The date and time form is correct from what I can see. Any help? TIA, Sean

Thu, Oct 19 2006 10:47 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sean


I think you'll need to use ansi format eg 2005-12-5 (thats yyyy-mm-dd). DBISAM has routines for taking a date or datetime and formatting it "properly"

Roy Lambert
Thu, Oct 19 2006 11:10 AMPermanent Link

"Sean M. McDermott"
Thanks Roy.. Sean

"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:66C7208B-4513-4C75-86E9-808535B62F1D@news.elevatesoft.com...
> Sean
>
>
> I think you'll need to use ansi format eg 2005-12-5 (thats yyyy-mm-dd).
> DBISAM has routines for taking a date or datetime and formatting it
> "properly"
>
> Roy Lambert
>

Mon, Oct 23 2006 5:05 AMPermanent Link

"Thomas Eg Jørgensen"

"Sean M. McDermott" <sean@horizoncanada.com> skrev i en meddelelse
news:E2D27D88-1185-4E0E-A94E-CF39992F7D0F@news.elevatesoft.com...
> Hi anyone, I am trying to query a table based on a timestamp field but it
> can't parse it. Error says... "Expected column name but found "12/5/2005
> 11:23 PM"
>
> The date and time form is correct from what I can see. Any help? TIA, Sean

I always use parameters:
   FQuery.SQL.Clear;
   FQuery.SQL.Add('INSERT INTO MyTable(MyTimestampColumn)');
   FQuery.SQL.Add('VALUES(:MyParameterName)');
   FQuery.ParamByName('MyParameterName').value=MyDelphiDateTimeVar;
   FQuery.ExecSQL;

This way you don't have to worry about date formatting...or any other type
of formating....

/Thomas

Mon, Oct 23 2006 5:41 AMPermanent Link

"Ian Branch"
Thomas Eg Jxrgensen wrote:
>
> This way you don't have to worry about date formatting...or any other type of
> formating....
>
Now that's sneaky!  I like it.  Well done.

Ian
Tue, Oct 24 2006 12:09 PMPermanent Link

Chris Erdal
"Thomas Eg Jørgensen" <thomas@hest.notaplan.com> wrote in
news:D9631B40-45E2-446B-B3AC-97087456815C@news.elevatesoft.com:

> I always use parameters:
>     FQuery.SQL.Clear;
>     FQuery.SQL.Add('INSERT INTO MyTable(MyTimestampColumn)');
>     FQuery.SQL.Add('VALUES(:MyParameterName)');
>     FQuery.ParamByName('MyParameterName').value=MyDelphiDateTimeVar;
>     FQuery.ExecSQL;
>
> This way you don't have to worry about date formatting...or any other
> type of formating....

but IIRC you need to specify the DataType in certain cases - I've never
quite understood why it usually goes OK but sometimes gives an error if you
try to assign a value without first setting the datatype.

--
Chris
(XP-Pro + Delphi 7 Architect + DBISAM 4.24 Build 1)
Image