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

Now() Bug in Online Developer

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.

1 ACCEPTED SOLUTION

Accepted Solutions
TimW
Level: Powered On

Re: Now() Bug in Online Developer

6 REPLIES 6
Community Support Team
Community Support Team

Re: Now() Bug in Online Developer

Hi @James_Hellfeier,

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:14.JPG

Set the OnSelect property of the "Patch" button to following formula:

Patch(
'[dbo].[TaskLists1]',
Defaults('[dbo].[TaskLists1]'),
{
Creator:"PowerApps Test",
Task_current_state:"Build",
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:

Patch function

 

Best regards,

Kris

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

Re: Now() Bug in Online Developer

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

 

powerapps1.PNG

 

while my server is receiving 11:08 AM when I Patch() ..... (7th column in the below picture)

 

powerapps3.PNG

.... you can see here that the timezone on my DataCard is set to "local", which matches my SQL server.

 

powrapps2.PNG

 

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.

 

James_Hellfeier
Level: Powered On

Re: Now() Bug in Online Developer

Note : Tried running this in the WebPlayer as well ... running into the same issues. This time, however, my times are 10 hours apart instead of 6.change.

Community Support Team
Community Support Team

Re: Now() Bug in Online Developer

Hi @James_Hellfeier,

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.

 

Best regards,

Kris

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

Re: Now() Bug in Online Developer

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.

TimW
Level: Powered On

Re: Now() Bug in Online Developer

Helpful resources

Announcements
thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,808)