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 Automate / Date/Time Format for S...
Power Automate
Answered

Date/Time Format for SharePoint Calendar

(0) ShareShare
ReportReport
Posted on by 5,836 Moderator

I am having some difficulty with Date/Time formats in my flow.

 

The Flow is triggered by PowerApps (Canvas App) and is creating events in a SharePoint calendar (classic calendar, not modern).   

 

There are 2 parts to this flow.  The first part creates the SharePoint item (Create Item action) and then the second part updates that item to set the 'AllDayEvent' flag (Send an HTTP Request to SharePoint).

 

In the original version of the flow, the create item was using the datepicker selected date with no additional formatting from the PowerApps collection.    The calendar item was created successfully, but had a random time in each item.   The update step (Send and HTTP Request to SharePoint) errors out with the error:

 

"error": {
"code": 502,
"source": "flow-apim-msmanaged-na-westus2-01.azure-apim.net",
"clientRequestId": "5ec2029c-f09f-4aee-84aa-1a63018c237d",
"message": "BadGateway",
"innerError": {
"message": "Invalid date/time value.\n\nA date/time field contains invalid data. Please check the value and try again.\r\nclientRequestId: 5ec2029c-f09f-4aee-84aa-1a63018c237d\r\nserviceRequestId: a6592d9f-6035-a000-9fa2-c271745bb65f",
"status": 502,
"errors": [
"-2130575332",
"Microsoft.SharePoint.SPException"
]
}
}
 
So I tried formatting the date coming out of PowerApps differently and that causes the create item step to fail.
 
Not sure what I need to do for it to see the date/time as valid.
Categories:
  • manuelstgomes Profile Picture
    6,643 on at

    Hi @JR-BejeweledOne 

     

    This is for sure a difference in the date format produced in your PowerApp and your SharePoint calendar.

     

    Please check:

    1. SharePoint's settings to validate what date/time format it's expecting (for example yyyy-mm-dd or yyyy-dd-mm).

    2. Check if the date is formated like that.

    3. When the error occurs please check the date that is failing. The error is silent sometimes because 2020-02-01 can be the the first of February or the second of January but SharePoint will accept it since it's a valid date.

     

    Hope this helps and makes sense.

     

    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.
    ​
    Cheers
    Manuel

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    I don't have any way to know which date is failing though.   It could be the EventDate (Start Date) or the End Date.   The error doesn't specify.  

     

    So the flow has these steps:

    1. Create Item

    2. Send HTTP Request (update item)

     

    In the create item step it's using the date from the PowerApps date picker, default format.   I haven't done any formatting of the date/time in the DatePicker and this is a canvas app, not a SharePoint list app.

     

    The event is being successfully created with the date from the datepicker in the PowerApp being used for the Start and End date fields in the sharepoint calendar.   This tells me that the format is correct otherwise it wouldn't be able to use it to create the event.

     

    I am not sure where this leaves me troubleshooting wise though.

  • Verified answer
    JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    After much trial and error and searching for answers I have resolved the problem. 

     

    In the original attempt to format the date I was using a formatDateTime expression that was referring to triggerBody.   This threatened to break my flow, which is being triggered by PowerApps.  

     

    Once I realized that triggerBody was causing the initial error, I tried multiple formatDateTime options and date conversions to no avail.   I stumbled upon a post that pointed me to the true solution which was reformatting the date in PowerApps before passing it to Flow.

     

    Here is the scenario and solution.

     

    PowerApp triggered flow to create an 'All Day' event in a SharePoint calendar.

     

    After creating the event using the Create Item SharePoint action, you need to use a Send HTTP Request to SharePoint action to set 'fAllDayEvent' to true.

     

    This will cause errors if you are not passing the correctly formatted date to update the EventDate and EndDates to drop the time.

     

    I set 2 dates.  One that is used to create the initial event in the calendar, this is just the standard date picker value and the second date is formatted to an ISO text format.  This is passed directly into the Send HTTP Request action.

     

    This is the formatted date to use in the Send HTTP request action.

    {EventDate: Text(dpDate.SelectedDate,"[$-en-US]yyyy-mm-ddThh:mm:ss")}

     

    First Action - Create Item uses the standard date picker valueFirst Action - Create Item uses the standard date picker value

     

     

    2nd Action, Send HTTP request, uses the specially formatted date2nd Action, Send HTTP request, uses the specially formatted date

     

     

     

  • Hedi69 Profile Picture
    30 on at

    Dear friend,

     

    Thank you so much for this procedure.

    One thing please: When you say: "I set 2 dates", could you please explain how to set these date ?

    I have only 3 columns in my list: Title, Start Date, End Date

    The event is properly created in the Sharepoint Calendar: "Absence Calendar"

    But I am not able to update the AlldayEvent to YES

    Thank you so much for your help.

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    I am setting two dates in the App itself.   One is just the standard date picker date and that is what is saved to the SharePoint Start Date and End date columns.   Both dates are saved to the collection that the flow is processing.

     

    {Date: dpDateInput.SelectedDate},
    {EventDate: Text(dpDateInput.SelectedDate,"[$-en-US]yyyy-mm-ddThh:mm:ss")}

     

    The date value is used when initially creating the SharePoint item.   As you can see it's just the value from the date picker.

     

    In the Send HTTP request action in the flow we are using the Event Date.  Notice how it's formatted.   This is what is considered an ISO format.  In my case it's formatted for US English.   You can modify that part to fit your needs.  The event date is not used in the Create SharePoint item action, only in the Send HTTPS request action.

     

    I hope this answers your question.  

  • Hedi69 Profile Picture
    30 on at

    Now I have an error with the URI:

    Hedi69_0-1643394818176.png

     

  • Hedi69 Profile Picture
    30 on at

    The name of my calendar is Absece Calendar

  • Hedi69 Profile Picture
    30 on at

    Absence Calendar sorry

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    What is the error you are getting and is this a classic SharePoint calendar list?

  • Hedi69 Profile Picture
    30 on at

    Yes classic view for the calendar

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 335 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard