cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
seanbrogan
Level 8

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

Re: Date Picker Incorrect Date & Drop

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Date Picker Incorrect Date & Drop

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

seanbrogan
Level 8

Re: Date Picker Incorrect Date & Drop

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
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: 357 members 7,051 guests
Please welcome our newest community members: