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

Unable to Save Date in Database

Hello,

I am unable to save Data in Database With Date Picker in the form could you please help me with the Solution.

I am Attaching the Screenshot of the same @Addend418..

3 REPLIES 3
Highlighted
Community Support
Community Support

Hi @Addend418 ,

Could you please share a bit more about your data source?

Do you also want to save the selected date value back to your data source when you submit your form data?

 

Based on the screenshot that you mentioned, I found that you added the DatePicker control outside the Edit form (not inside the form). If you want to save the selected date value back to your data source when you submit your form data, I afraid that there is no direct way to achieve your needs.

 

If you have already owned a Date time type column in your data source, you could enable the date time field data card within your Edit form directly, then you could select proper date within the Date time field data card, and click the "Submit" button to submit the whole form data (including date time field value).

 

If you just want to add the DatePicker control outside the Edit form, and save the selected date value along with the submitted form data, I think the Patch function could achieve your needs.

Please set the OnSuccess property of the Edit form (EditForm2) to following:

// Add following formula
Patch(
      'Your Data Source',
       EditForm2.LastSubmit,
       {
         DateField: DatePicker2.SelectedDate
       }
);
Back()

Note: The DateField represents the Date Type field in your data source.

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

Thanks For Your response,

1. I am Working on a Demo Project with Azure Database in SQL.

2. Yes I want to  save the selected date value back to my data source when i will submit my form data.

3. I have Added the DatePicker in the EditForm I have Attached the Screenshot for the same.

4. I Have also added Date Value field in the Database For the same.

5. My only Issue is to link the Datepicker to the Datafield in the Database(SQL) so that I can Save the Date in the Particular Field and then View the same in a New Gallery.

 

Highlighted

Hi @Addend418 ,

Do you add multiple Edit forms in your app? Do these Edit form connect to same Azure SQL Table?

 

If you have added a Date time field in your SQL Table, you just need to add a Edit form in your app, then connect the Edit form to your SQL Table, then enable the date time field within this Edit form, then the date time field data card in your Edit form would be linked to the date time field in your SQL Table dynamically.

Note: You just need to enable the date time field in the Edit form, the link would be created automatically, you do not need to do extra operations.

 

If you split your SQL Table fields into multiple Edit forms, and you want to submit your multiple forms data into single one record in your SQL Table, I afraid the SubmitForm function could not achieve your needs. The SubmitForm function would add each submitted form data as separated row in your SQL Table.

 

As an fixed solution, I think the Patch function could achieve your needs. You could add a "Submit" button in your Last Edit form screen, and add "Next" button in other Edit forms screen. Click the "Next" button to navigate to next Edit form screen.

Set the OnSelect property of the "Submit" button to following:

Patch(
      '[dbo].[YourSQLTable]',
      Defaults('[dbo].[YourSQLTable]'),
      EditForm1.Updates,
      EditForm2.Updates,
      EditForm3.Updates,
      ...
      ...
)

Note: I assume that these EditForms (EditForm1, EditForm2, EditForm3, .....) are connected to same SQL Table data source

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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 (14,791)