Hi Everyone, Actually I am facing some issue with Date and Time Attribute in mendix because of time zone difference. I want session time instead of UTC time and I want data of last 24 hours so I used this addHours([%CurrentDateTime%],-24) for getting it. Here I want to convert it in session time how can I do it ?
I don’t think you need to. In Mendix, all dates are stored in UTC time. Based on how your app is configured (and how the attribute is defined) users will either see UTC time (for non Localized atttributes) or their session tiem (for Localized attributes). However, the underlying value is still the same. For more information, see this https://docs.mendix.com/refguide/date-and-time-handling/
Date time is a hard topic and I’m assuming you didn’t turn off date localization. To troubleshoot your issue, I suggest the following.
Put 2 data grids to a page, one has no filter, the other has filter as you wish. Then you can compare and verify the result. Mendix will convert all dates to the same time zone (your time zone).
If you want to verify data at backend, you need to make sure comparing values are in the same time zone. I will use SQL Server for my example.
You can use AT TIME ZONE to see actual values (in your time zone) in your database instead of UTC. It is like SELECT CreatedDate, CreatedDate AT TIME ZONE ‘UTC’ AT TIME ZONE ‘India Standard Time’ (I believe you are in IST).
Try to use GETUTCDATE() function to query data like SELECT CreatedDate WHERE CreatedDate > DATEADD(dd, -1, GETUTCDATE())