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?
Solved! Go to Solution.
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.
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.
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.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
203 | |
180 | |
62 | |
32 | |
30 |
User | Count |
---|---|
324 | |
269 | |
104 | |
74 | |
56 |