Skip to Content
Menu
This question has been flagged
1 Odpoveď
1119 Zobrazenia

I am executing the following queries:

SELECT * FROM stock_quant WHERE write_date > '2021-06-19 15:12:11' and the Odoo API also returns records that have write_date = '2021-06-19 15:12:11'

I have executed the following query and SELECT * FROM stock_quant WHERE write_date <= '2021-06-19 15:12:11' and the Odoo API doesn not return records that have write_date'2021-06-19 15:12:11'.


I would expect that for the first query the api will return only records that have write_date greater than '2021-06-19 15:12:11'. And in the second query I expect to get records that have write_date less then or equal to '2021-06-19 15:12:11', but this does not happen.

Could you please let me know why there is such a behaviour? 



Avatar
Zrušiť
Best Answer

I believe it is because the timestamp in the database includes microseconds but when you look at the record are the value has been trunicated to seconds. So when you see a record with time 15:12:11, in the database it is stored as 15:12:11.222222 (for example) and is therefore greater than 15:12:11

You can confirm this is how the values are stored by connecting to the db from the shell and looking at the values in your write_date field.

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
2
aug 25
2826
1
júl 25
1150
1
aug 25
1152
0
máj 25
1563
2
apr 25
3763