cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seanbrogan
Advocate V
Advocate V

Date Picker Incorrect Date & Drop

I'm having a nightmare with datepickers and getting the correct date to show. I would also like to be able to drop the time and have the date only if anyone has a solution for that.

 

Bit of background. Been having a nightmare with dates in Powerapps from day one. Had to use all sorts of fiddles to get the ISO format to work (as opposed to mm/dd/yy which was default) And now I'm flat getting the incorrect date. Seems to be since the clock changed.

 

So I have a form where users can submit holiday requests, which of course has a date picker for start dates. If a user now pics 23/4/2019 as their start date and then submits the form, the date that appears in my SQL table is 22/4/2019 23:00:00

 

11pm the day before!

 

What I would like is if a user selects 23/4/2019 as the start date, then 23/4/2019 appears in the datasource, as selected, without the time.

I have the format of the date picker set to ""dd/mm/yy" And the update for that datacard is "DateValue5.SelectedDate". On selecting a confirm buttin I use "SubmitForm(FormName)" and that's when I get the incorrect date.

 

Has anyone seen anything like this in terms of having the incorrect date appear or found a way to drop the time. I had tried for the update field "DateValue(DateValue5.SelectedDate)" to no avail.

 

Would changing DateTimeZone.Local to .UTC have any effect (I have a strong feeling what powerapps thinks is my "local" region is not my 'local' region)

 

Also, does UTC in this context handle daylight savings?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@seanbrogan 

Your SQL dates are going to be in UTC.  So, you simply need to adjust for that and store a UTC date.

Have a look at the TimeZoneOffset function. This will give you some more details.

 

What you need to do is to change your Update property to

   DataAdd(DateValue5.SelectedDate, TimeZoneOffset(DateValue5.SelectedDate), Minutes)

 

To display the proper value, you'll want to convert from UTC.  So set your Default property of the DataCard to:

   DateAdd(yourSqlDateField, -TimeZoneOffset(yourSqlDateField), Minutes)

 

Daylight savings time is handled by your regional settings which are accounted for in the Date functions in powerapps.  UTC is "universal" and does not change by regional changes.  And, again, UTC is the default for your SQL...so you just need to do the conversion. 

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User III
Super User III

@seanbrogan 

Your SQL dates are going to be in UTC.  So, you simply need to adjust for that and store a UTC date.

Have a look at the TimeZoneOffset function. This will give you some more details.

 

What you need to do is to change your Update property to

   DataAdd(DateValue5.SelectedDate, TimeZoneOffset(DateValue5.SelectedDate), Minutes)

 

To display the proper value, you'll want to convert from UTC.  So set your Default property of the DataCard to:

   DateAdd(yourSqlDateField, -TimeZoneOffset(yourSqlDateField), Minutes)

 

Daylight savings time is handled by your regional settings which are accounted for in the Date functions in powerapps.  UTC is "universal" and does not change by regional changes.  And, again, UTC is the default for your SQL...so you just need to do the conversion. 

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Thanks @RandyHayes 

 

I've got it working at the moment. I deleted the "start date" card from the form and added a new one. Then chaned that to DateTimeZone.UTC. I set the hour and minute value to default to "00" and hid them from the user.

Now if a user selectes 23/4/19 in the date picker I get 23/4/19 00:00 in my SQL table. I would prefer without the time at all but this is managable for now.



Thanks for your help.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,424)