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

datepicker results in one day off in SharePoint and in app

This has been reported before, but I can't see that it is resolved in any way.

 

An app generated from SharePoint. The date picker is set to DateTimeZone.Local. The SharePoint field is date only.

 

When a new record is created in the app and saved, the date immediately shows one day less IN THE APP and in SharePoint

When a new record is created in SharePoint, the app shows the correct date.

When a record is edited in the app, the existing correct date will be changed to one day less IN THE APP and in SharePoint.

 

Please, what can be done to avoid that behaviour? I'm in New Zealand. All my computers are regional settings for New Zealand. My mobile devices are all set to New Zealand. My SharePoint online tenant and site collection and site settings are all for New Zealand. The app date picker is set to DateTimeZone.Local. So, why is the date changing from what is selected in the date picker of the app????

 

Please fix this. 

3 REPLIES 3
Community Support Team
Community Support Team

Re: datepicker results in one day off in SharePoint and in app

@IngeborgNZ,

 

Check the response from staff CarlosFigueira at ‎05-10-2016 10:19 PM:

"

You're hitting a current limitation in the DatePicker control (or the handling of dates in general). The issue is that if you set the default date as a text value with no time component and time zone set to UTC (the 'Z' at the end), it will convert to a Date value, and the date will be converted to a date in the local time zone. If you are anywhere west of UTC (i.e., almost all of the Western hemisphere, incluinding the Americas), then it will end up in the day before. You can see exactly which date the control is being given by displaying the following formula in a text box:

Text: Text(DateTimeValue("2016-05-12T00:00:00Z", DateTimeFormat.LongDateTime24))

We're working on a solution for this scenario (dates stored as UTC strings). There's a workaround that you can use in the interim, where you can calculate the exact delta that you would need to add to your date. In the example below, the date string is stored in a text input, and the logic is executed based on a button press, but it can be adapted for other controls (please let us know more details about your scenario if you need help).

TextInput1.Default: "2016-05-12T00:00:00Z"
Button1.OnSelect:
    UpdateContext({ d: DateTimeValue(TextInput1.Text) });
    UpdateContext({ dUtc: Text(Year(d), "0000") & "-" Text(Month(d), "00") & "-" & Text(Day(d), "00") & "T00:00:00Z" });
    UpdateContext({ dAdj: DateDiff(DateTimeValue(dUtc), d, Days) });
    UpdateContext({ dForPicker: DateAdd(d, dAdj, Days) })
DatePicker1.DefaultDate: dForPicker

"

Thread reference:

Date displayed is one day off

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
IngeborgNZ
Level: Powered On

Re: datepicker results in one day off in SharePoint and in app

@v-micsh-msft Thank you.

 

I don't understand. Please help me out here.

 

That post is over a year old. Are you saying that date pickers are pretty much unusable for anyone who does not live in UTC and that this has not been fixed in over a year?

 

Does everybody who works with date pickers have to jump through these hoops? 

 

 

Community Support Team
Community Support Team

Re: datepicker results in one day off in SharePoint and in app

Hi @IngeborgNZ,

 

Please check the newly published blog:

PowerApps Newest Features Releases Address Top User Requests!

There is a new function announced to work with the time Zone, TimeZoneOffset, please follow the document below for the usage:

DateAdd, DateDiff, and TimeZoneOffset functions in PowerApps

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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 (Last 30 Days)
Users online (3,796)