Recently, Now() has been generating and storing inconsistent DateTime values in my SQL Databse when "previewing" apps in the online web developer.
I've been running into this issue when testing an app in the online web developer. What happens is that after editing an app for a while (about 30-60 min), I enter "Preview the App" and create / send a new record to my SQL database using the Now() function to capture the current date and time. What has been happening is that the first record I create generates a seemingly-random DateTIme value (sometimes off by a day, sometimes a couple of hours, sometimes more than a day, etc...). If I then create a second record in the App Preview, however, it generates and stores the correct date and time that it should (the time that the Now() function was orginally called ... when I loaded the web developer about 30-60 minutes prior.)
A few notes :
- I am in PTC timezone ( -8 ) and I know that PowerApps uses UTC, thus I adjust for this when viewing the dates sent from PowerApps into SQL. This is not a timezone issue, given I notice these random DateTime values when I view the dates directly in the SQL database.
- When Now() is behaving properly, it sends the correct time (in my PTC timezone) into the SQL database and I view these as correct.
Given these Now() values are random and "correct" themselves after creating a second record, I am to believe that this is a bug in the "Preview App" mode of the online developer tool.
Solved! Go to Solution.
How do you save data into your SQL table within your app? Using SubmitForm function or Patch function?
I have made a test on my side, and don't have the issue that you mentioned. The screenshot as below:
Set the OnSelect property of the "Patch" button to following formula:
Task_due_date: Now() /* <-- Task_due_date is a DateTime type column in my SQL table */
Please take a try with above solution, then check if the issue is solved.
In addition, please also make sure that the Time Zone of your SQL Server is same with your local time zone.
If the issue still exists, please take a try to re-create your app, then save data into your SQL table using Patch function, then check if the issue is solved.
More details about Patch function, please check the following article:
I've been submitting forms with SubmitForm() instead of Patch(), however I updated my app to submit with :
Patch( 'dbo' , Defaults( 'dbo' ) , NewForm.Updates )
where the DATETIME field being sent to my SQL server is populated by a calendar card in the NewForm with default set to Now() and its timezone set to the same timezone as my SQL server. Note : this is not a custom card and was linked to my SQL server by choosing it as a datafield when making a Form set to New().
Since updating using Patch(), my issue has gotten worse. Now it sends a consistent time to the SQL server, however this time is off a wacky amount. I reloaded my app (to reset Now() to the current time) and it is currently 5:30 AM, which my date datacard shows in my app by the way, however my SQL server is receiving a time of 10:54 AM ... again my timezone is PTC, which is 8 hours off of UTC, so this shouldn't be a timezone issue. Also note that it's off not on a perfect hour, also suggesting that this may not be a timezone issue.
Reloaded my app once again and my datacard is showing 5:34 AM
while my server is receiving 11:08 AM when I Patch() ..... (7th column in the below picture)
.... you can see here that the timezone on my DataCard is set to "local", which matches my SQL server.
As a matter of fact, when I load up the entry in PowerApps, I'm shown this 11:08 AM value in the data field of the record, meaning PowerApps is correctly adjusting for the timezones.
This leads me to believe that PowerApps is sending DateTime values into my SQL server, not offset by a timezone amount and inconsistent with the updates of the Datacard that it's pushing.
Which time zone does your SQL Server belongs to? Have you customized the time zone for your browser?
Further, is the SQL Server existed in same computer device where you run your app?
Currently, I could not reproduce your issue on my side. Based on the screenshot that you provided, it may be a time zone issue.
In addition, please also check if you have customized the time zone for your browser. Please make sure the time zone your browser belongs to is same with your local time zone.
Please also make sure the time zone your SQL Server belongs to is same with your local time zone.
If the issue still exists, please consider re-create your app, check if the issue is solved.
Timezone in my browser is set to the standard Local Timezone.
Timezone for my SQL server (located on the same premise as me) is also set to Local.
Thinking the app may just have something wrong with it. I've been creating another app that uses Now() to grab times and then Patch() those into a different table in the same server and haven't been having any issues with wonky times.
Fill out a quick form to claim your user group badge now!
Find out where you can attend!
Features releasing from October 2019 through March 2020
The largest Power BI, Power Platform, and Data conference in New Zealand