cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jgohl
Level: Powered On

DateTimeValue and TimeValue getting different results (DST) between app running on iOS and app running on Windows desktop.

I have a date/time string coming from a flow/SQL stored procedure containing current date and time in UTC format.  That's one hour behind in British Standard Time during Daylight Saving Time.


I can see the exact string value of the date before I format it, one hour behind as expected.

When I need to convert this to DateTime scope using DateTimeValue() (to later format using Text()) and display this, on mobile the function tries to be clever and converts it to the correct DST time.

When running the same app on Windows desktop, DateTimeValue() will return the original time, one hour behind as expected.

 

I have tried getting my stored procedure to deliver the correct time based on DST, but the DateTimeValue() function still is one hour ahead on mobile no matter what I do.  This wouldn't be a huge issue if PowerApps contained a function to determine what platform that app was running on, but there isn't.

 

I have also tried to use TimeZoneOffset() which produces amount of offset minutes, this comes back correct as -60, but when using DateDiff() this can only accept a DateTime scope value, which I can only get from the DateTimeValue() that is wrong.

 

Please fix asap.

1 ACCEPTED SOLUTION

Accepted Solutions
KroonOfficeSol
Level 10

Re: DateTimeValue and TimeValue getting different results (DST) between app running on iOS and app running on Windows desktop.

@jgohl 

 

Good to hear you find a workaround for your problem.

 

But It's not the case that the IOS behaves different, but I would think the time for that IOS device is set improper for your timezone. So go into the time settings of the device and reset the time. You could better look and change it there at the source of the issue.

 

Paul

4 REPLIES 4
KroonOfficeSol
Level 10

Re: DateTimeValue and TimeValue getting different results (DST) between app running on iOS and app running on Windows desktop.

He Joghl,

I would think the time settings on your IOS is wrong so I wonder if you tried to run the app on an android and a different IOS device?

In the Netherlands we have winter and summer time so there is a hour difference in the time based on the moment of calculation. As a fix I add an int column [UTCDiff] in my table and write the utctime and the UTCdifference to the datasource. With both you can created a view on the sql side in which you calculated the region time and convert this to a varchar. This formatting is created because Flow will convert your date to text if you haven't already. The view you use in your stored procedure. So PowerApps will get the time you want to show. I experienced the same issue as you on different devices and came up with this fix, maybe it will work for you to.

Btw, I use a text representation of the utcdate which I write from PowerApps to my sql server and not a datevalue. This works like a charm. Btw2: you don't need to convert the date at the sql side, but you can use the varchar in the insert/update statement. Sql will parse this to the date fir you automatically.

Hope this helps,

Paul
Highlighted
jgohl
Level: Powered On

Re: DateTimeValue and TimeValue getting different results (DST) between app running on iOS and app running on Windows desktop.

Thanks for your input Paul.

 

This doesn't get around the fact that DateTimeValue() behaves differently on iOS and it shouldn't.

 

I can confirm the problem doesn't exist on one version of android (others not tested).  No settings on iOS will determine the outcome of DateTimeValue(), and why should there be.  It wouldn't be an acceptable solution to have to get users to turn a setting off outside the app.

 

For now I have detected the hour difference using Hour() between server time and local device time, if there is a difference then I use DateAdd(<servertime>, -TimeZoneOffset(), Minutes).

 

KroonOfficeSol
Level 10

Re: DateTimeValue and TimeValue getting different results (DST) between app running on iOS and app running on Windows desktop.

@jgohl 

 

Good to hear you find a workaround for your problem.

 

But It's not the case that the IOS behaves different, but I would think the time for that IOS device is set improper for your timezone. So go into the time settings of the device and reset the time. You could better look and change it there at the source of the issue.

 

Paul

jgohl
Level: Powered On

Re: DateTimeValue and TimeValue getting different results (DST) between app running on iOS and app running on Windows desktop.

So this turns out to be a either a bug in iOS (since I disabled "Set Time Automatically" and re-enabled it) and the time is now correct.  However, just because this has fixed the issue, this does not isolate the problem to iOS, it could be a problem with the PowerApps app on iOS.