If you are working with MSACCESS
- Code: Select all Expand view
oRs:Filter := "LDATE >= #2023-01-01# AND HDATE < #2023-02-01#"
If you are working with Microsoft SQL
- Code: Select all Expand view
oRs:Filter := "LDATE >= '2023-01-01' AND HDATE < '2023-02-01'"
Note: It is safer to use "HDATE < (date + 1 )" than "HDATE <= (date)", because many RDBMS use datetime fields.
How to easily generate these expressions?
We better make it a habit to open an ADO connection using FW_OpenAdoConnection() of FWH instead of opening on our own with ADODB.Connection.
If we open using FWH function FW_OpenAdoConnection, all the other ADO functions know the RDMS used and function in a say appropriate to the RDMBS.
Please try this:
- Code: Select all Expand view
lDate := STOD( "20230101" )
hDate := STOD( "20230131" )
oCn := FW_OpenAdoConnection( "xbrtest.mdb" )
? C := FW_AdoApplyParams( "LDATE >= ? AND HDATE < ?", { lDate, hDate + 1 } )
oCn:Close()
oCn := FW_MSSQLDB()
? C := FW_AdoApplyParams( "LDATE >= ? AND HDATE < ?", { lDate, hDate + 1 } )