Hello I'm trying to make a conversion between Datetime and Date and the date is always going to the next day. Why is that?




Hi Alexandre,

On mobile, conversion to and from UTC (not GMT) is taking place on various occasions, not always completely transparent. For example, all DateTime variables in the database are stored as UTC, and converted to local time when used in the app. However, there's some situations that this conversion isn't applied to values shown in the debugger, and I think you ran into that. I'd advise Bernardo's approach to convert a DateTime to a Date, although if I'd have to guess, the result would be the same, as the UTC date/time is converted to local time first.

Kilian Hekhuis wrote:

Hi Alexandre,

On mobile, conversion to and from UTC (not GMT) is taking place on various occasions, not always completely transparent. For example, all DateTime variables in the database are stored as UTC, and converted to local time when used in the app. However, there's some situations that this conversion isn't applied to values shown in the debugger, and I think you ran into that. I'd advise Bernardo's approach to convert a DateTime to a Date, although if I'd have to guess, the result would be the same, as the UTC date/time is converted to local time first.


Bernardo's approach?

Bernardo seems to have deleted his post. He advised to use DateTimeToDate() to strip the time from the DateTime.

Yes, I do not know if I understood correctly what he wanted. But from what I understand, I gave the idea of using DateTimeToDate() to transform DateTime into Date.


I can ensure you that don't work...

I think the confusion here stems from the debugger showing the date as-is before conversion to local time, while every other use of a DateTime will first convert it to local time. There's afaik no way around that.