cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

SQL Server Time wrong displayed in label field, two hour difference

The field from the MS SQL Server shows "2017-08-24 09:00:00.000" (This field or the contents can not be changed).

When connected to a Label in PA it shows "24.08.2017 11:00" - which is a differenz of two hours. Is there a formatting option that would allow PA to show the correct time?  

As a workaround we are using "Text(DateAdd( ThisItem.mobStart; -2; Hours );"[$-de-DE]dd-mm-yyyy hh:mm" )" but we are unsure if this is the best way to work with this issue.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: SQL Server Time wrong displayed in label field, two hour difference

@Anonymous is correct - since the date is stored in Azure, it's assumed to be in the UTC time zone. And I'm assuming that the type of the column in your SQL table is datetime - which doesn't have any time zone information, so UTC is assumed.

 

Currently Germany (again, assuming where you are, based on the [de-DE] that was added to your formula) is 2 hours ahead of UTC, so subtracting 2 hours will solve the problem. But if the date is outside the daylight saving time (DST) period (where it should be only 1 hour ahead of UTC), then it would not work.

 

Ideally you would use a column type in SQL that has time zone information (such as datetimeoffset), but if that is not possible, then you can use the TimeZoneOffset function to add the appropriate time and that is also DST aware. If you set your formula to

Text(
    DateAdd(
        ThisItem.mobStart;
        TimeZoneOffset(ThisItem.mobStart);
        Minutes);
    "[$-de-DE]dd-mm-yyyy hh:mm" )

Then you should have the time that is represented in the SQL table show in your app.

View solution in original post

3 REPLIES 3
Highlighted
Anonymous
Not applicable

Re: SQL Server Time wrong displayed in label field, two hour difference

If your SQL is on Azure, it stores all dates in UTC format.

All Datepicker controls have a DatetimeZone property that can be set to UTC or Local. 

 

I am assuming you are -2 hours from UTC time? If that is the case and you want the date to match the one stored in SQL, then just change this property to UTC.

 

Hope this helps

 

Highlighted
Frequent Visitor

Re: SQL Server Time wrong displayed in label field, two hour difference

I also got the same. At the moment your solution is the best workaround. You need to use adddate
Highlighted
Power Apps
Power Apps

Re: SQL Server Time wrong displayed in label field, two hour difference

@Anonymous is correct - since the date is stored in Azure, it's assumed to be in the UTC time zone. And I'm assuming that the type of the column in your SQL table is datetime - which doesn't have any time zone information, so UTC is assumed.

 

Currently Germany (again, assuming where you are, based on the [de-DE] that was added to your formula) is 2 hours ahead of UTC, so subtracting 2 hours will solve the problem. But if the date is outside the daylight saving time (DST) period (where it should be only 1 hour ahead of UTC), then it would not work.

 

Ideally you would use a column type in SQL that has time zone information (such as datetimeoffset), but if that is not possible, then you can use the TimeZoneOffset function to add the appropriate time and that is also DST aware. If you set your formula to

Text(
    DateAdd(
        ThisItem.mobStart;
        TimeZoneOffset(ThisItem.mobStart);
        Minutes);
    "[$-de-DE]dd-mm-yyyy hh:mm" )

Then you should have the time that is represented in the SQL table show in your app.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,321)