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

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
PowerApps Staff CarlosFigueira
PowerApps Staff

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
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

 

Jakubp
Level: Powered On

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
PowerApps Staff CarlosFigueira
PowerApps Staff

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 92 members 5,375 guests
Please welcome our newest community members: