cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mooler
Frequent Visitor

Excel column date to outlook calendar event (how to format the date)

Hello!
I've scanned the community for a couple of days and been trying to solve this but comes up short.
I've got a excelfile with tables where one of the columns is a date formated one. Via a flow I'd like this date to transfer to a outlook calendar event. 
This to make my teacher be able to just fill in the excel file and automatically it would create a event.
So far the event is created on the right day but I can't find a way to get the time of day to transfer from excel to calendar.
This is what I got and this gives me a event in the calendar but obvioulsy without specific time. The formatDateTime is:

formatDateTime(addDays('1900-01-01', add(int(items('Apply_to_each')?['endDate']),-2)), 'yyyy-MM-dd')
But as soon as I try to edit the date format of the excel date column to include time I get an error that the integer is invalid. So I tried to replace int with float but to no avail.

I could use a hint how to proceed with this to get it working properly. New to PA so it's a bit tedious and slow 🙂 


Screen Shot 2020-10-26 at 09.34.54.pngScreen Shot 2020-10-26 at 09.33.34.pngScreen Shot 2020-10-26 at 09.24.33.pngScreen Shot 2020-10-26 at 09.14.10.png

23 REPLIES 23
v-alzhan-msft
Community Support
Community Support

Hi @mooler ,

 

Please take a try with expression below:

formatDateTime(addDays('1900-01-01', add(int(items('Apply_to_each')?['endDate']),-2)), 'yyyy-MM-ddTHH:mm:ss')

 

Best regards,

Alice       

 

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

Yes I have tried that solution before but it gives me the followin error. 

 

Screen Shot 2020-10-26 at 13.03.41.png

This is the expresson for the startDate:

 

formatDateTime(addDays('1900-01-01', add(int(items('Apply_to_each')?['startDate']),-2)), 'yyyy-MM-ddTHH:mm:ss')

 

And this is the expression for the endDate:

@{formatDateTime(addDays('1900-01-01', add(int(items('Apply_to_each')?['startDate']),-2)), 'yyyy-MM-ddTHH:mm:ss')}

The format in excel for the date is still the same as before, could it be that I need to edit the columnformatting in excel? As I said I'm fairly new to this kind of connectors so I do not see the problem as of now.

Screen Shot 2020-10-26 at 13.11.09.png

Anonymous
Not applicable

@mooler ,

 

Can you provide the Output from one of the failed runs to see what format Power Automate was receiving the date from Excel?

 

Normally, dates are stored as numbers for an even day, and with decimals if there is a time component. Since you tried using float instead of int, I assume you know this, but I figured I would throw it in anyway.

 

If the error is that the Int() function isn't getting an integer, we need to know what it IS getting.

 

also, what error do you get when using float()?

 

thanks,

 

Kyle

From a failed run I don't get any output the error message just the "invalid template" error that I posted. Same if I replace int with a float.

If I use:

formatDateTime(addDays('1900-01-01', add(int(items('Apply_to_each')?['endDate']),-2)), 'yyyy-MM-dd')

and format the excel column without a specific time (just date):

 Screen Shot 2020-10-26 at 18.04.38.png
Then I get integer output as:
Screen Shot 2020-10-26 at 18.06.44.png
The flow then runs and creates a event in Outlook but the event is created at 00.00 as the output states.
Then if I just edit the excel column to add a time to the date as below:
Screen Shot 2020-10-26 at 18.15.28.png
I don't alter anything else, when I then run the flow I get:
Screen Shot 2020-10-26 at 18.17.05.png
If i try all the date formats in the excel colum I get that same error.
If I edit the "inte" to a "float" i get the invalidtemplate error.

So how the heck do I get the output accepted with the time as well? It probably is some simple thing I'm missing but after all the trial and errors I've tried I'm probably blid to what is missing!


Anonymous
Not applicable

@mooler ,

 

have you tried just removing the int() part of the expression altogether?

 

since excel stores the DateTime as a number anyway, forcing the type conversion may be unneccessary... 

 

I'm not sure this is the problem...i'm just troubleshooting at this point.

 

Kyle

I'm greatful for any input!

 

Unfortunately that is not a valid expression. 

 

formatDateTime(addDays('1900-01-01', add('startDate'),-2)), 'yyyy-MM-dd')

 

And this give the same invalid template error as before: 

 

formatDateTime(addDays('1900-01-01', 'startDate',-2), 'yyyy-MM-dd')

 

 If I use just the dynamic content variables i get a "bad request" error. This was my first choice before diving in to the expressions part of this. 
Like this:

Screen Shot 2020-10-26 at 20.44.42.png

The input:
Screen Shot 2020-10-26 at 20.48.52.png
and output error:

 

{"statusCode":400,"headers":{"Pragma":"no-cache","x-ms-request-id":"9a5710cf-b99e-49b1-95ff-f678985c58ac","Strict-Transport-Security":"max-age=31536000; includeSubDomains","X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY","Cache-Control":"no-store, no-cache","Set-Cookie":"ARRAffinity=fa9050a86380ecce883d8ff2e805dd22d58cc29332b6761a0fc08c7d82b3fa74;Path=/;HttpOnly;Secure;Domain=office365-ne.azconn-ne-01.p.azurewebsites.net,ARRAffinitySameSite=fa9050a86380ecce883d8ff2e805dd22d58cc29332b6761a0fc08c7d82b3fa74;Path=/;HttpOnly;SameSite=None;Secure;Domain=office365-ne.azconn-ne-01.p.azurewebsites.net","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"false","Date":"Mon, 26 Oct 2020 18:42:49 GMT","Content-Length":"289","Content-Type":"application/json","Expires":"-1"},"body":{"status":400,"message":"String was not recognized as a valid DateTime.\r\nclientRequestId: 9a5710cf-b99e-49b1-95ff-f678985c58ac","error":{"message":"String was not recognized as a valid DateTime."},"source":"office365-ne.azconn-ne-01.p.azurewebsites.net"}}

 

Anonymous
Not applicable

@mooler ,

 

I was thinking more something like this, only removing the int() portion of your above expression and leaving everything else (maybe you already tried this):

 

formatDateTime(addDays('1900-01-01', add(items('Apply_to_each')?['endDate'],-2)), 'yyyy-MM-dd')

 

If that doesn't work, I would suggest you put a compose action block in your flow somewhere before the error and pass in one of our dates from Excel to see what its output is....

Yes, I did try that one and it gives a "invalid template" error. 
If I put a compose between the "get row" and the "apply to each" I get the following.
Input:

va[{"@odata.etag":"","ItemInternalId":"ed853fa9-c30e-4a12-a575-9e1d9a91d452","eventName":"Historia","startDate":"43831.4166666667","endDate":"43831.4583333333","arskurs":"8A","rooms":"13"}]

Output:

va[{"@odata.etag":"","ItemInternalId":"b2e8a8ed-103b-4296-a95e-c7d59c9b7a21","eventName":"Historia","startDate":"43831.4166666667","endDate":"43831.4583333333","arskurs":"8A","rooms":"13"}]

 It seems fine to me, but then again I do not know what format outlook demands for it to work.

This whole idea originated from a article where the user just used dynamic content variables and it worked. https://www.ariclevin.com/Flow/Post/outlook-events-onedrive-excel 

Anonymous
Not applicable

@mooler ,

 

For some reason, I cannot see the message you posted in between my last two responses, but I do remember you mentioning that you originally tried using the dynamic content and it didn't work, but I cannot remember what you said regarding why it didn't work. could you please provide that information again?

 

It is odd since, as you said, the article is just using the dynamic content.

 

Unfortunately, changing the date format in excel will not change how the date/time is stored in Excel. It will still be 4XXXX.XXXXX

 

thanks,

Kyle

Strange it must not have been posted.
Anyway, yes I did try the dynamic content route first as this article explained https://www.ariclevin.com/Flow/Post/outlook-events-onedrive-excel 

This is the dynamic content way.
Screen Shot 2020-10-26 at 21.42.33.pngScreen Shot 2020-10-26 at 21.48.22.pngScreen Shot 2020-10-26 at 21.49.02.png
The output error sais wrong date format:

{"statusCode":400,"headers":{"Pragma":"no-cache","x-ms-request-id":"4934d0b8-198f-44aa-8fc4-637bfde4bf19","Strict-Transport-Security":"max-age=31536000; includeSubDomains","X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY","Cache-Control":"no-store, no-cache","Set-Cookie":"ARRAffinity=2dec40ee271a11b22b991f97343df846ec15685ecd916e17e0cdc237e9bff764;Path=/;HttpOnly;Secure;Domain=office365-ne.azconn-ne-01.p.azurewebsites.net,ARRAffinitySameSite=2dec40ee271a11b22b991f97343df846ec15685ecd916e17e0cdc237e9bff764;Path=/;HttpOnly;SameSite=None;Secure;Domain=office365-ne.azconn-ne-01.p.azurewebsites.net","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"true","Date":"Mon, 26 Oct 2020 19:46:59 GMT","Content-Length":"289","Content-Type":"application/json","Expires":"-1"},"body":{"status":400,"message":"String was not recognized as a valid DateTime.\r\nclientRequestId: 4934d0b8-198f-44aa-8fc4-637bfde4bf19","error":{"message":"String was not recognized as a valid DateTime."},"source":"office365-ne.azconn-ne-01.p.azurewebsites.net"}}

 

The input and output in a compose is:
Input:

va[{"@odata.etag":"","ItemInternalId":"86df82b7-140c-48f9-8308-f4f66f070ac2","eventName":"Historia","startDate":"43831","endDate":"43831","arskurs":"8A","rooms":"13"}]

 Output:

va[{"@odata.etag":"","ItemInternalId":"86df82b7-140c-48f9-8308-f4f66f070ac2","eventName":"Historia","startDate":"43831","endDate":"43831","arskurs":"8A","rooms":"13"}]
Anonymous
Not applicable

@mooler ,

 

I'm sorry, but I'm at a loss...

 

this is past my area of experience...

 

@v-alzhan-msft , do you have any suggestions?

 

thanks,

Kyle

Anonymous
Not applicable

@mooler ,

 

 

the only other thing i can think of, is putting the date from excel into a compose or a variable, and then trying to reference that in your formatDateTime() function...

I'm just as lost, the integer generates fine but the create event connector to Outlook doesn't accept it. Go figures 😄

Anonymous
Not applicable

This is probably the point where we need to ask someone like  @Jcook@Pstork1 , or @ScottShearer 

Pstork1
Most Valuable Professional
Most Valuable Professional

You are on the right track, but the CreateEventv4 action requires that the start and end times be in ISO 8601 format and they must include both Date and Time.  Try using the following codes.

formatDateTime(addDays('1900-01-01', add(int(items('Apply_to_each')?['startDate']),-2)), 'o')

formatDateTime(addDays('1900-01-01', add(int(items('Apply_to_each')?['endDate']),-2)), 'o')

The 'o' specifies that the output is in ISO 8601 time/date format. 



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

Ok! Unfortunately I don't get a success using that expression. 
I did put a compose between to get the input and output. This is what is shown.

 

 

Input:
[
  {
    "@odata.etag": "",
    "ItemInternalId": "5dce440f-b11a-4f09-b336-bb094babcd5e",
    "eventName": "Historia",
    "startDate": "27/10/2020  10:00:00 AM",
    "endDate": "27/10/2020  11:00:00 AM",
    "arskurs": "8A",
    "rooms": "13"
  }
]

Output:
[
  {
    "@odata.etag": "",
    "ItemInternalId": "5dce440f-b11a-4f09-b336-bb094babcd5e",
    "eventName": "Historia",
    "startDate": "27/10/2020  10:00:00 AM",
    "endDate": "27/10/2020  11:00:00 AM",
    "arskurs": "8A",
    "rooms": "13"
  }
]

 

But the error is this:
Screen Shot 2020-10-27 at 15.01.00.png

And this is where I wonder if this could be due to the language settings in excel. My excel is in swedish but PA is in english (I've tried to force all apps to english but word en excel just won't change language).
INT is apparently HELTAL in swedish excel. Could this be the cause? I'll be damned if I know how to get excel to be english though 😄

*edit* did manage to get english as global language and checked that the INT variable was the prefered language in excel. But still get the same error.

Pstork1
Most Valuable Professional
Most Valuable Professional

I took a closer look at what you are doing.  The Format isn't your problem.  Its this part of the formula

int(items('Apply_to_each')?['startDate']),-2)

The startDate is a DateTime value and you can't use int() with that in Power Automate.  Are you trying to adjust the time from the Excel Spreadsheet by subtracting two hours?  If so, then use this in place of the int()

addHours(items('Apply_to_each')?['startDate'],-2)


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

Thanks for trying to help!
Unfortunately this did not work, I'm so far into this I'm loosing sight over what has worked and what doesn't 😄

If I try your example:

Just adding:
addHours(items('Apply_to_each')?['startDate'],-2)
or trying it like this:
formatDateTime(addDays('1900-01-01', addHours(items('Apply_to_each')?['startDate'],-2)), 'o')

I get:
Screen Shot 2020-10-27 at 18.52.10.png 

So then I'm back with the ISO problem of the date value. I could use a fresh start to all this all I want to do is get a row from excel -> create a event in outlook. Next step is to figure out how a event is removed or edited if a row is edited or removed.
Any help is appreciated! 


Pstork1
Most Valuable Professional
Most Valuable Professional

What exactly are you trying to do with the startdate?  Why are you both adding hours and adding days?  If you can explain what you are attempting I can try to help.  But you are now getting a different error so we are definitely working on the section of the formula that is the problem.



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

Helpful resources

Announcements

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS   Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!   Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!       Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!   UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!   European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!     Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!     For more events, click the image below to visit the Microsoft Community Days website.      

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!

Tuesday Tip: Getting Started with Private Messages & Macros

Welcome to TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   This Week's Tip: Private Messaging & Macros in Power Apps Community   Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member!   Our Knowledge Base article about private messaging and macros is the best place to find out more. Check it out today and discover some key tips and tricks when it comes to messages and macros:   Private Messaging: Learn how to enable private messages in your community profile and ensure you’re connected with other community membersMacros Explained: Discover the convenience of macros—prewritten text snippets that save time when posting in forums or sending private messagesCreating Macros: Follow simple steps to create your own macros for efficient communication within the Power Apps CommunityUsage Guide: Understand how to apply macros in posts and private messages, enhancing your interaction with the Community For detailed instructions and more information, visit the full page in your community today:Power Apps: Enabling Private Messaging & How to Use Macros (Power Apps)Power Automate: Enabling Private Messaging & How to Use Macros (Power Automate)  Copilot Studio: Enabling Private Messaging &How to Use Macros (Copilot Studio) Power Pages: Enabling Private Messaging & How to Use Macros (Power Pages)

Users online (4,551)