cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JTA88
Helper I
Helper I

DateTimeValue language conversion error

Apologies if this has already been covered somewhere else, but I've been unable to find an example of the exact issue I'm facing...

 

I'm using the Office365Outlook.V4CalendarPostItem function, and have encountered an infuriating quirk that I can't figure out.

 

I have a knowledge fair stall that has 2 presentation times throughout a day. I want the user to be able to click a button to add one of these presentations to their Outlook calendar.

 

With reference to this Shane Young video, I've managed to create a button that sends a calendar event - but where it should be scheduling it in for the November 24th, 2022, it's actually scheduling it for November 12th, 2023.

 

The syntax I'm using is:

 

OnSelect = 

Office365Outlook.V4CalendarPostItem(
LookUp(Office365Outlook.CalendarGetTables().value, DisplayName = "Calendar").Name,
"Knowledge Fair: " & DataCardValue2,
DateAdd(DateTimeValue(Label5.Text, "en"), TimeZoneOffset(), Minutes),
DateAdd(DateTimeValue(Label5.Text, "en"), 10 + TimeZoneOffset(), Minutes),
"(UTC) Coordinated Universal Time")

 

For context, I'm based in the UK, and using GB date format; "Label5.Text" reads: 24/11/2022 16:00 (i.e. dd/mm/yyyy hh:mm). So I figure the problem is the language setting, right? Leaving it blank and using "en" result in the same incorrectly timed appointment. But if I change "en" to "en-GB", it breaks and I get an error message: "String was not recognized as a valid DateTime."

 

Can anyone clue me in as to where this is going wrong? Feel like I'm missing something obvious. I've tried a whole bunch of different approaches; the above text is the only version that's worked enough to send the appointment, but not much good if it's for the wrong day and time!

 

Demo2.png

4 REPLIES 4
v-chengfen-msft
Microsoft
Microsoft

Hi @JTA88 ,

The reason why you met this problem is that:

DateAdd(DateTimeValue(Label6.Text, "en"), TimeZoneOffset(), Minutes),  this  date format is mm:DD:yyyy.

So when Label5.Text is 24/11/2022 16:00, StartTime will become 12/11/2023 8:00 AM.

Maybe you can try:

Office365Outlook.V4CalendarPostItem(

LookUp(Office365Outlook.CalendarGetTables().value,DisplayName="FCuser").Name,

"Knowledge Fair: " & DataCardValue2,

DateAdd(DateTimeValue(Index(Split(Label5,"/"),2).Result&"/"&Index(Split(Label5,"/"),1).Result&"/"&Index(Split(Label5,"/"),3).Result, "en"), TimeZoneOffset(), Minutes),

DateAdd(DateTimeValue(Index(Split(Label5,"/"),2).Result&"/"&Index(Split(Label5,"/"),1).Result&"/"&Index(Split(Label5,"/"),3).Result, "en"), 10 + TimeZoneOffset(), Minutes),

"(UTC) Coordinated Universal Time")

 

Best Regards

Cheng Feng

Hi @v-chengfen-msft,

 

Thanks for this. Having just tried it, I get a different error message:

 

Office635Outlook.V4CalendarPostItem failed: the method 'V4CalendarPostItem' has an invalid value for parameter 'table'

 

The only difference I could spot in the table field you recommended was that you'd changed the "Calendar" in my initial formula to "FCuser"; having changed it back, though, I get the same old "String was not recognized as a valid DateTime" error again.

 

Apologies, I'm no expert when it comes to PowerApps - am I messing up something basic? I may end up having to ditch this feature, I don't feel proficient enough to make it work 😑

Hi @JTA88 ,

Maybe you could add several labels, put the time value in it, and see which part is wrong. If it is convenient, please show the screenshot of the wrong part (pay attention to protect personal privacy).

 

vchengfenmsft_0-1665482232348.png

Best Regards

Cheng Feng

JTA88
Helper I
Helper I

Hi @v-chengfen-msft ,

 

See, this is where I'm completely stumped. When I split it out into separate text boxes, there are no errors - everything works as expected in the text boxes, and there are no errors showing for the button formula:

 

Demo3.png

 

But as soon as I press the button, it breaks; the whole formula is red-underlined and I get the following message in the details section:

 

Demo4.png

Makes zero sense to me 🙃

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,857)