Unable to retrieve date in UTC using OQL

0
I’m trying to get date and time in UTC using OQL datePart() function but it always returns the date and time in local timezone. Is there any way to retrieve date in UTC from OQL?   Below is my OQL Select (CAST(DATEPART(day,e/dateOfBirth)AS STRING) +’/’+ CAST(DATEPART(month,e/dateOfBirth) AS STRING) +’/’+ CAST(DATEPART(year,e/dateOfBirth)AS STRING) +’/’+ CAST(DATEPART(hour,e/dateOfBirth)AS STRING) +’/’+ CAST(DATEPART(minute,e/dateOfBirth)AS STRING)+’/’+CAST(DATEPART(second,e/dateOfBirth)AS STRING)) AS DOB from Employee.Employee as e The results will huge based on where clause. As performance is concerned I can’t use loop to get date in UTC, I have to send the raw response from OQL. Is this achievable using OQL? Thank you in advance!
asked
2 answers
0

Hi,

You can check this https://forum.mendix.com/link/space/microflows/questions/110651

answered
0

Timestamps are always stored as UTC in Mendix, they may be converted at different points: at retrieval and at when showing.

As your result is a string, it will be no issue between the attribute you're storing the data in and the viewer.

Apparently a conversion takes place when retrieving, for which I see 2 possible solutions:

  • Run the query using the system user (scheduled event, queued task or ExecuteAsUser JavaAction). Please check if this solves the issue
  • Turn off conversions by setting the option “localize time” on original attribute to False
answered