Converting UTC time into Session time

0
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 ?  
asked
2 answers
0

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/

answered
0

Hi Neha,

 

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.

  1. 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).
  2. 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())
  3. See https://docs.mendix.com/refguide/date-and-time-handling/
  4. See https://academy.mendix.com/link/paths/106/Advanced-Domain-Model-Skills, section #7. It is highly recommended.
  5. Considering if you should use date localization or not. In some cases, it causes many issues. Think and make a wise choice.
answered