cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimSutt
Advocate II
Advocate II

Update Timestamp Datacard to Now() Upon Submit?

I have a simple form with a hidden timestamp datacard which I want to set to Now() when the user clicks a Submit button.  I do not want to set the default value for the datacard to Now() as I want to capture the timestamp at the exact time of submit.  The data is added to a SQL database.  Is there a way to fill the timestamp datacard on the form with the value of Now() and then add the record to the database in the same step?  I'm struggling because PowerApps has taken my timestamp record and broken out into date, hours, and minutes fields when I added the datacard.  

3 ACCEPTED SOLUTIONS

Accepted Solutions
KrishnaV
Super User
Super User

Hi @JimSutt ,

 

Yes it is the case with Now() on to a label, I assume you are doing sumitform(formname), dot the same with a patch as below:

Patch(sqltable,default(sqltable),{column1:value1,........,timestamp:now()});

This will get the live timestamp.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

eka24
Super User
Super User

Do you want to get the exact time of submit.

On the OnSelect of the Submit button Set a variable:

Set(varTimenow, Now ()); SubmitForm (YourFormName)

 

Or

For time only

Set(varTimenow, Text(Now (),h"mm:ss")); SubmitForm (YourFormName)

 

Then put the variable name: varTimenow into the Default of the Datacarvalue.

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

v-bofeng-msft
Community Support
Community Support

Hi @JimSutt :

Firstly,thanks to @eka24 and @KrishnaV for providing solutions. If their solution solves your problem, I suggest you mark one or all of the responses as solutions, so that more people can see it.

Secondly,let me explain why you encounted this prolem.

The point is Now is a volatile function. Each time one of these functions is evaluated it returns a different value.

If nothing else changes in the formula then it will have the same value throughout the execution of your app.

For example, a label control with Label1.Text = Now() will not change while your app is active. Only closing and reopening the app will result in a new value.

When used in a behavior formula, volatile functions will be evaluated each time the behavior formula is evaluated. See below for an example.

Best Regards,
Bof

View solution in original post

4 REPLIES 4
KrishnaV
Super User
Super User

Hi @JimSutt ,

 

Yes it is the case with Now() on to a label, I assume you are doing sumitform(formname), dot the same with a patch as below:

Patch(sqltable,default(sqltable),{column1:value1,........,timestamp:now()});

This will get the live timestamp.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
eka24
Super User
Super User

Do you want to get the exact time of submit.

On the OnSelect of the Submit button Set a variable:

Set(varTimenow, Now ()); SubmitForm (YourFormName)

 

Or

For time only

Set(varTimenow, Text(Now (),h"mm:ss")); SubmitForm (YourFormName)

 

Then put the variable name: varTimenow into the Default of the Datacarvalue.

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

v-bofeng-msft
Community Support
Community Support

Hi @JimSutt :

Firstly,thanks to @eka24 and @KrishnaV for providing solutions. If their solution solves your problem, I suggest you mark one or all of the responses as solutions, so that more people can see it.

Secondly,let me explain why you encounted this prolem.

The point is Now is a volatile function. Each time one of these functions is evaluated it returns a different value.

If nothing else changes in the formula then it will have the same value throughout the execution of your app.

For example, a label control with Label1.Text = Now() will not change while your app is active. Only closing and reopening the app will result in a new value.

When used in a behavior formula, volatile functions will be evaluated each time the behavior formula is evaluated. See below for an example.

Best Regards,
Bof

Thank you @KrishnaV , @eka24 , and @v-bofeng-msft for your help!  

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,048)