date timezone difference

0
how to get the same date from the sql server database to the Mendix application. for example if the date in the SQL Server database is 07/25/2024, but in the Mendix application it showing as 07/24/2024, also in the excel export it is giving as 07/24/2024. Please help to fetch the same date from database into Mendix.
asked
1 answers
3

Dates can be very confusing, but is actually quite simple: in the database all datetimestamps are stored in UTC, and when presented in a UI it usually shows the localized date&time, unless you define otherwise.

To get a good grip on the datetimestamp's content, set a breakpoint in you flow, just before you show the page. In the debugger the variable now shows first the UTC datetimestamp, followed by the localized date&time.

So your issue is about presentation. You have two options to make it show the UTC date:

- in the domain model, set the attribute's Type 'Localize' to false. Now always UTC is shown. And you are all set;

- or instead of showing the attribute in your page, rather create another variable having the value

formatDate($yourEntity/YourDateTimeAttribute, "yyyy-MM-dd")

 

answered