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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / V4CalendarPostItem iss...
Power Apps
Answered

V4CalendarPostItem issue - "String was not recognized as a valid DateTime" for some users

(0) ShareShare
ReportReport
Posted on by 15

Hi all, hope you're doing well.

 

PREMISE: I have an issue with my Power App when creating a calendar invite with the V4CalendarPostItem function, where for some users the app errors and reports the dates provided aren't recognised as valid times.

 

I have a Power App with features to help a user log their holidays. One feature involves sending out a calendar invite on Outlook to all people the user intends to notify about their holiday (so that the recipients know when they're on holiday). Here's a screenshot of the interface with some dates:

 

HL date range interface w dates.PNG

 

For some context, there are two invites that are sent out when the user clicks submit (among other things): one invite is sent out to the user themselves to mark them as away; and another invite is sent out to all their recipients. The code below is used to send an invite to all recipients:

 

// Send the external calendar invite, stores the event ID as 'external'
Set(
 external, 
 Office365Outlook.V4CalendarPostItem(
 varUserCalendarId, 
 myself.FullName & " - Holiday",

 // DateValue(Text(StartDateNew.SelectedDate)),
 // DateValue(Text(EndDateNew.SelectedDate + 1)),
 DateValue(Text(StartDateNew.SelectedDate, "yyyy-mm-dd")),
 DateValue(Text(EndDateNew.SelectedDate + 1, "yyyy-mm-dd")),
 
 "UTC", 
 {
 requiredAttendees: Concat(InviteesNew.SelectedItems.Email, Email, ";"),
 responseRequested: false, 
 isAllDay: true
 }
 )
);

 

With the app, I'm able to set a holiday from 25th March 2024 until 28th March 2024, for example, and this creates an item (the bottom of the two items) in my calendar over those dates.

 

calendar invite 25-03-24 to 28-03-24 v2.PNG

However, there's one user of the app in particular who sent out an invite over the same date range, and they receive the errors below:

 

GreatPanda3_2-1701255075833.png

Office365Outlook.V4CalendarPostItem failed: {
 "status":400, 
 "message": "String was not recognized as a valid DateTime.\r\nclientRequestId: 0a811417-2c39-46c8-9fce-624dd97ea1b8", 
 "error": {
 "message": "String was not recgonized as a valid DateTime." 
 }, 
 "source": "office365-eus2.azconn-eus2-003.p.azurewebsites.net"
}

 

They've also tried the date ranges below but still receive the error (no calendar invites are sent out), whereas I have tried them and don't receive any errors (the calendar invite is also successfully sent out). Here are some dates they've tried:

  • 28th May to 31st May
  • 8th July to 12th July

 

I've had a look at other posts on the forum where others have tried formatting the date to work for both US and UK formats, so I've added a "yyyy-mm-dd" mask to the dates, but the error still persists. There doesn't seem to be anything that suggests the user has US-specific settings on their Outlook account, so I'm not sure what's wrong. This issue doesn't seem to be happening for other users either, which is really weird.


Thanks for taking the time to read this post, I'm happy to provide more details for any questions.

Categories:
I have the same question (0)
  • MudassarSZ365 Profile Picture
    591 on at

    Hi @GreatPanda3 ,

    You can try this

    Office365Outlook.V4CalendarPostItem(
     varUserCalendarId, 
     myself.FullName & " - Holiday",
     Text(StartDateNew.SelectedDate, DateTimeFormat.UTC),
     Text(DateAdd(EndDateNew.SelectedDate, 1, Days), DateTimeFormat.UTC),
     "UTC", 
     {
     requiredAttendees: Concat(InviteesNew.SelectedItems.Email, Email, ";"),
     responseRequested: false, 
     isAllDay: true
     }
    )

    If you manage to resolve the issue with this guidance, please mark the solution and leave a thumbs up. Thank you! 😊

  • GreatPanda3 Profile Picture
    15 on at

    Hi @MudassarSZ365, thanks for the response. I'll try this out with the user and let you know how it goes.

  • MudassarSZ365 Profile Picture
    591 on at

    @GreatPanda3 ,

    ok I am waiting for your response. if you face any issue contact me

    thanks

  • GreatPanda3 Profile Picture
    15 on at

    Hi @MudassarSZ365, sorry for the late reply, and thanks for keeping yourself open. I've tested out the code with the user, and they're finally able to submit holidays after not being able to at all, which is great! However, there seems to be another issue that happens for both myself and the user.

    When submitting a holiday from 25th March 2024 - 28th March 2024, the calendar invite runs through 25th March 2024 - 28th March 2024 (which is expected)...

    ... but when submitting a holiday from 28th May 2024 - 31st May 2024, the calendar invite runs through 27th May 2024 - 31st May 2024 (but it should start from 28th May 2024, which is unexpected).


    (images of the holiday in the app vs. the user's calendar)

    GreatPanda3_0-1701439824195.png

    GreatPanda3_1-1701440159205.png

     

    I created a test label to use Text(StartDateNew.SelectedDate, DateTimeFormat.UTC) and this is what's displayed (notice how it's 23:00 - one hour behind midnight):

    GreatPanda3_2-1701440575820.png


    I think this might be due to a time zone issue somehow, but I'm not sure how to fix this even if this might be the case. Would you be able to help me please?

  • GreatPanda3 Profile Picture
    15 on at

    It's been a while since the last post, but I found out what the problem is and have a solution for it.

    I'm using a Windows device, and there are certain time zones that are affected by daylight savings, so the clock moves back by one hour when daylight savings comes around. If your settings use "(UTC+00:00) Dublin, Edinburgh, Lisbon, London" (for example), this causes the hour to move back during May and July, whereas using "(UTC) Coordinated Universal Time" doesn't produce this effect.

    GreatPanda3_0-1701981409106.png

    Since I'm only concerned with the date and not the time, I removed the time element by replacing "DateTimeFormat.UTC" with "DateTimeFormat.ShortDate", which stopped the time from going back by 1 hour.

     

    Here's the code I used when sending out the holiday calendar invite to recipients, which doesn't produce the original "string not valid as a DateTime value" error either:

    // Send the external calendar invite, stores the event ID as 'external'
    Set(
     external, 
     Office365Outlook.V4CalendarPostItem(
     varUserCalendarId, 
     myself.FullName & " - Holiday",
    
     // Text(StartDateNew.SelectedDate, DateTimeFormat.UTC),
     // Text(DateAdd(EndDateNew.SelectedDate, 1, TimeUnit.Days), DateTimeFormat.UTC),
    
     Text(StartDateNew.SelectedDate, DateTimeFormat.ShortDate),
     Text(DateAdd(EndDateNew.SelectedDate, 1, TimeUnit.Days), DateTimeFormat.ShortDate),
    
     "UTC", 
     {
     requiredAttendees: Concat(InviteesNew.SelectedItems.Email, Email, ";"),
     responseRequested: false, 
     isAllDay: true
     }
     )
    );


    Hope this helps someone, thanks @MudassarSZ365 for the support!

  • Verified answer
    GreatPanda3 Profile Picture
    15 on at

    It's been a while longer since my last post. I tested the code above with the user, but encountered the same error as I did at the start of this thread, so the above solution doesn't solve my problem.

     

    However, since the "yyyy-mm-ddT00:00:00.000Z" format seems to work perfectly, I decided to go ahead with that and force the time to always be midnight as below:

     

    Text(StartDateNew.SelectedDate, "yyyy-mm-dd") & "T00:00:00.000Z",
    Text(DateAdd(EndDateNew.SelectedDate, 1, TimeUnit.Days), "yyyy-mm-dd") & "T00:00:00.000Z",

     

    This solution fixes all problems mentioned in the thread (invalid text as date time value, and the "one hour back" issue):

    // Send the external calendar invite, stores the event ID as 'external'
    Set(
     external,
     Office365Outlook.V4CalendarPostItem(
     varUserCalendarId,
     myself.FullName & " - Holiday",
    
     Text(StartDateNew.SelectedDate, "yyyy-mm-dd") & "T00:00:00.000Z",
     Text(DateAdd(EndDateNew.SelectedDate, 1, TimeUnit.Days), "yyyy-mm-dd") & "T00:00:00.000Z",
    
     "UTC",
     {
     requiredAttendees: Concat(InviteesNew.SelectedItems.Email, Email, ";"),
     responseRequested: false,
     isAllDay: true
     }
     )
    );

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard