cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Storing datatime to sql database

I have an Edit form on which I have CreationDate field.

I would like to update this field with current datetime and update the database when submitform() is invoked.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Storing datatime to sql database

From your questions:
1. If you submitting the whole form with a button, then:
Put this variable on the Onvisible of the screen:
Set(MyTimeNow,Now())

Then in the default of the datefield datacardvalue put:
If(YourFormName.Mode=FormMode.Edit,MyTimeNow,Parent.Default)

On hiding / disable the field, you can put this formula on the Displaymode of the field If(YourFormName.Mode=FormMode.Edit,View,Edit) . This will prevent them from manually changing the field.

2. But if you are to change on the datefield without submitting the whole form then on the OnSelect of the button put:
Patch('[dbo].[avlist] ',YourTexbox.Text, {DatefieldColumn:Now()})

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Re: Storing datatime to sql database

Try this
Patch('[dbo].[avlist] ',YourTexbox.Text, {DatefieldColumn:Now()})

Change '[dbo].[avlist] ' to actual sql table
Highlighted
Frequent Visitor

Re: Storing datatime to sql database

Where should I put that syntax?

It will be in datacard update or submit button?

One doubt, can I hide this in the form or say I do not add this field, but in submit button update the current datatime to database?

Is it possible? If yes, How?

Highlighted
Super User III
Super User III

Re: Storing datatime to sql database

From your questions:
1. If you submitting the whole form with a button, then:
Put this variable on the Onvisible of the screen:
Set(MyTimeNow,Now())

Then in the default of the datefield datacardvalue put:
If(YourFormName.Mode=FormMode.Edit,MyTimeNow,Parent.Default)

On hiding / disable the field, you can put this formula on the Displaymode of the field If(YourFormName.Mode=FormMode.Edit,View,Edit) . This will prevent them from manually changing the field.

2. But if you are to change on the datefield without submitting the whole form then on the OnSelect of the button put:
Patch('[dbo].[avlist] ',YourTexbox.Text, {DatefieldColumn:Now()})

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,286)