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

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

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

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

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

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!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,987)