Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
1123 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
ago 25
2832
1
lug 25
1152
1
ago 25
1152
0
mag 25
1570
2
apr 25
3766