Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
1121 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
2
août 25
2832
1
juil. 25
1152
1
août 25
1152
0
mai 25
1570
2
avr. 25
3766