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

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
eka24 Community Champion
Community Champion

Re: Storing datatime to sql database

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

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

eka24 Community Champion
Community Champion

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
secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

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