cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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

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
Super User III
Super User III

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

Change '[dbo].[avlist] ' to actual sql table
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?

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
News & Announcements

Community Blog

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

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (5,417)