Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2023-03

Microsft Access Date Select statment

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Larry Dalton

Using Microsoft Access Driver (*.mdb, *.accdb), on Windows 11, with Lazarus 2.22.4.

TSQLQuery
'Select * from bbt1300
Where Trans_date between beginning_date and ending_date;' where all three are datetimes;

No matter how I format the beginning and ending dates, it doesn't work. If I format the dates in quoted strings ('20230101') or any variation, I get the incompatible types errors.

if I format the dates as unquoted strings, (20230101, 01012023, 2023-02-01,2023/02/01) or any other variations, if pulls all the records in the table, or no have even used the DateTimeToFileTime value as longints converted to strings without quotes. The pulled no records.

I have to use MS Access for this application. Any help out there? -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20230324/684a7887/attachment.htm>

Reply by email

Jean SUZINEAU
to Larry Dalton

Le 24/03/2023 ? 21:48, Larry Dalton via lazarus a ?crit?:

Where Trans_date between beginning_date and ending_date;'

May be it would be better? with params ?

"Where Trans_date between :beginning_date and :ending_date;"

and then supposing? your TSQLQuery is declared as sqlq :

 ? sqlq.Params['beginning_date'].asDate:= EncodeDate( 2023, 01, 01);

Reply by email

Werner Pamler
to Larry Dalton: Using Microsoft Access Driver (*.mdb, *.accdb), on Windows 11, with Lazarus 2.22.4.…
Larry Dalton wrote
No matter how I format the beginning and ending dates, it doesn't work. If I format the dates in quoted strings ('20230101') or any variation, I get the incompatible types errors.

Enclose the date/time by '#', put the date parts in year/month/day order and separate them by slashes:

 ??? Query.SQL.Add('SELECT * FROM Events WHERE (StartTime >=
#2019/01/15#) AND (StartTime < #2019/01/16#)');

But using query parameters is always the better way.

Reply by email

Larry Dalton
to Werner Pamler

Thanks. I?ll learn the parameters.

Sent from my iPhone

Show quoted text 16 lines
On Mar 24, 2023, at 19:39, Werner Pamler via lazarus wrote: ?Am 24.03.2023 um 21:48 schrieb Larry Dalton via lazarus: > No matter how I format the beginning and ending dates, it doesn't work. If I format the dates in quoted strings ('20230101') or any variation, I get the incompatible types errors. Enclose the date/time by '#', put the date parts in year/month/day order and separate them by slashes: Query.SQL.Add('SELECT * FROM Events WHERE (StartTime >= #2019/01/15#) AND (StartTime < #2019/01/16#)'); But using query parameters is always the better way. -- _______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

Reply by email