For more details about Text function, please see this article below:
Thanks for the answers, but my problem is a little different. Sorry for my short question. I try to explain the problem in more details.
I have an SQL database table with a datetime field. There is a button on my PowerApps form. When the user press the button I want to write the current timestamp to the database. Now my button's OnSelect is the following:
Currently I am in CET timezone and after the Patch I see the local time in the database. But the database standard is to store the datetime values in UTC. So I need to convert the Now() to UTC somehow, but not as a text value, I need datetime value.
Another interesting thing that I see the datetime values on the PowerApps form converted from UTC to local. According to this I see a 1 hour different time comparing to the real button-press time.
1, I press the button at 10:00am local time
2, Patch function sends 10:00am to database
3, Database writes 10:00am to the table, which means 10:00am UTC
4, Database sends back the data to the app 10:00am UTC
5, App displays 10:00am UTC in local time, so I see on the form 11:00am
So, it looks that in write process there is no time conversion from local to UTC but in the show process there is a time conversion from UTC to local.
According to it I want to convert the Now() value "manually" from local to UTC before the Patch function.
Additional information: The database is an On-Premise SQL database of Dynamics AX 2012. I use On-Premise Data Gateway between SQL database and PowerApp.
For all who are looking for a solutions in this matter:
In the patch function use
What this does is writing the time as a UTC time (so UTC = Region Time). So in the database the actual time is stored.
To display the right Time you then have to convert the Region Time to UTC Time again
What happens is that you store a UTC Time which is equal to the Region Time. When you get this time back from the (sql) datebase this UTC time is converted to the region time and the DateAdd function adds or substracts the time in minutes between the region time and UTC Time. So the actual time (UTC) safed in the database is shown.
Be aware that this workaround is not suitable when the time must change with different region, ' cause nine o'clock will be always nine o'clock.
Check it out!
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