Comparing dates in local query

Comparing dates in local query

  

Hi all,

I have a local query in my mobile app in which I want to filter all the records on a specific date (the current date). I have records that have a datetime attribute that have the current date as their date component, but still the filter datetimetodate() of this attribute = currdate() returns no results.

Has anyone experienced this strange behaviour before or any suggestions?


Thanks,


Artuur

Hi Artuur,

Be aware that the Platform stores date/times in the local database as UTC, so if you inspect the content with devtools, you're seeing UTC. So the question is, do you have records that contain the current date in UTC (but not in local time), or do these records actually contain the local current date? What happens if you remove the filter, are you still getting the records that have a local date of today?

Hi Kilian,

thanks for the quick reply. Using the devtools, I actually see a datetime that is 1 hour less than the datetime of the same record in the database entity. So: the database records have 2017-05-15 00:00:00, but the local records don't have the current date (2017-05-14 23:00:00). The local current date and UTC should be the same for me, here in the UK. When I remove the datefilter, the records are there. I also displayed the datetime of a local record in a message in my app and that showed the same as the database entity (2017-05-15 00:00:00).

Solution

Hi Artuur,

I assume that in the UK it's also DST, so you're actually one hour ahead of UTC.

Solution

That explains it, thanks for your help. 

You're most welcome :)