When I try to run the below query I get no result even though the date time is same as that in the table.
The BillDateTime column is of TEXT Data type
SELECT * FROM BillingTransaction WHERE BillDateTime <= datetime('2021-09-19 07:21:31.371766')
| BillNo | VechicleNo | BillDateTime | LoadType | BillAmount | FirstWeight | SecondWeight |
|---|---|---|---|---|---|---|
| 1 | ka04sdfl | 2021-09-19 07:21:31.371766 | EMPTY | 30 | 400 | 0 |
The function
datetime()strips off everything after the seconds, because it is equivalent to:The result of:
is:
So your code is equivalent to:
and this is why you don't get any rows.
You don't need the function
datetime(), because the values of the columnBillDateTimeare strings in the proper ISO format.You can do direct comparisons with them: