web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patching a date and ti...
Power Apps
Answered

Patching a date and time to a Sharepoint list

(1) ShareShare
ReportReport
Posted on by 106
I added in the Patch function to be able to update the Start and End time in Sharepoint, but now for some reason no matter what date I select, it adds the current date to the Sharepoint list. I chose 3/22/2025 in my app, but it updated the list to 3/20/2025 (today). The time updates properly, just not the date. Although I have an older version of the app from before I added in the time element and the patch function and the date was updated properly. I even added in the highlighted checks below to make sure it was grabbing the date and time correctly. This is the formula for the OnSelect option of the Submit button: 
SubmitForm(
Form1
);Set(varPopUpVisible,true);
Patch(
    'PTO',
    LookUp('PTO', ID = Last('PTO').ID),
    {
        'Start Date': DateTimeValue(
           Text(
DataCardValue2
.Value, "[$-en-US]yyyy-mm-dd") & " " &
    Text(Value(
DropdownCanvas1
.Selected.Value), "00") & ":" &
    Text(Value(
DropdownCanvas2
.Selected.Value), "00") & " " &
    
DropdownCanvas3
.Selected.Value
),
        'End Date': DateTimeValue(
           Text(
DataCardValue3
.Value, "[$-en-US]yyyy-mm-dd") & " " &
    Text(Value(
DropdownCanvas1_1
.Selected.Value), "00") & ":" &
    Text(Value(
DropdownCanvas2_1
.Selected.Value), "00") & " " &
    
DropdownCanvas3_1
.Selected.Value
)
    }
)
Screenshot 1.png
I have the same question (0)
  • Suggested answer
    venturemavenwill Profile Picture
    1,198 Super User 2026 Season 1 on at
    Try to save DatacardValue2.Value and DataCardValue3.Value to a variable before you press submit
     
    I think the problem here is that the Submit resets the form. When you then Patch the datasource, the selected dates no longer exists. 
     
    You can also access the values you submitted using the property Form1.LastSubmit
     
    Please let me know if this helps with your issue. 
  • MC-08030409-0 Profile Picture
    106 on at
    I changed the OnSelect property to include the variables but it didn't work. Does it matter that Submit form takes place first? I'm not sure if the order matters. But also, I guess I'm confused why the variables would make a difference because it is patching the time correctly, just not the dates. Although the times were added after the fact, so maybe the times aren't getting reset like the dates are.
     
    SubmitForm(Form1);Set(varPopUpVisible,true);Set(StartDateVar,DataCardValue2.Value);Set(EndDateVar,DataCardValue3.Value);
    Patch(
        'PTO',
        LookUp('PTO',ID = Last('PTO').ID),
        {
            'Start Date': DateTimeValue(
               Text(StartDateVar, "[$-en-US]yyyy-mm-dd") & " " &
        Text(Value(DropdownCanvas1.Selected.Value), "00") & ":" &
        Text(Value(DropdownCanvas2.Selected.Value), "00") & " " &
        DropdownCanvas3.Selected.Value
    ),
            'End Date': DateTimeValue(
               Text(EndDateVar, "[$-en-US]yyyy-mm-dd") & " " &
        Text(Value(DropdownCanvas1_1.Selected.Value), "00") & ":" &
        Text(Value(DropdownCanvas2_1.Selected.Value), "00") & " " &
        DropdownCanvas3_1.Selected.Value
    )
        }
    )
  • Verified answer
    ronaldwalcott Profile Picture
    3,906 Moderator on at
    The Set should be before SubmitForm.
     
    Are these
    Set(StartDateVar,DataCardValue2.Value);Set(EndDateVar,DataCardValue3.Value)
    only date values?
     
    These
    Text(Value(DropdownCanvas1.Selected.Value), "00") & ":" &
        Text(Value(DropdownCanvas2.Selected.Value), "00") & " " &
        DropdownCanvas3.Selected.Value
    might not be accessible after the Submit. Are they part of the form? If so, why would you need to Patch?
    If you are saving to the SharePoint list in the SubmitForm you can include those fields and initialize the values so that the SubmitForm would update them.
     
     
     
     
    To set default values such as a last updated date set the datacard containing the date in the card to a context variable such as TheUpdatedDate (initialize this value in the OnVisible of the screen). In the OnSelect of the Submit button before the submit form update the context variable to Now().
    This may be the better approach to update any value before update. Items can be added to the form, set to invisible and the values updated in the Submit.

     
     
     
  • MC-08030409-0 Profile Picture
    106 on at
    Yes, DataCardValue2 and DataCardValue3 are only date values. I highlighted them in the attached image.
     
    So the dropdown selections are the start and end times. There's not a time picker box so I had to add dropdowns for them, but the time is patching correctly somehow. Just not the dates.
    Screenshot 1.png
  • MC-08030409-0 Profile Picture
    106 on at
    Actually, I switched the Set to be before the Submit and it worked that time.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 463

#2
WarrenBelz Profile Picture

WarrenBelz 364 Most Valuable Professional

#3
11manish Profile Picture

11manish 275

Last 30 days Overall leaderboard