cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PierrickBIT
Regular Visitor

Import date from excel rows to HTML table

Well, first, I know there have been like dozens of topics like this and I'm sorry to bother.

 

I've read for many hours now and cannot get a solution.

 

Pasted below are some good links that helped people

Power Automate flow HTML Table Formatting in Email | Flows & SharePoint - YouTube

https://powerusers.microsoft.com/t5/General-Power-Automate/Manipulating-Flow-Excel-Date/td-p/365876

https://powerusers.microsoft.com/t5/Building-Flows/Datetime-string-must-match-ISO-8601-format-Can-t-...

https://www.bythedevs.com/post/working-with-date-time-data-of-excel-in-power-automate

 

Unfortunately, maybe I'm cursed, maybe I'm dumb, but guess what? I cannot get out of this.

 

Anyway, here we go: an excel sheet, formatted as a table, contains (among other things) dates. Those dates are Date-type-excel-formatted. I added a column, containing same dates but formatted as text, because... why not, just to run some tests.

PierrickBIT_0-1675104377669.png

 

Here is the very beginning of the flow. Note that I forced the date format to ISO8601 (as I read a couple of times to be the magic trick)

PierrickBIT_1-1675104547922.png

 

Next step is to select the data I will later paste in the HTML table

PierrickBIT_2-1675104671063.png

The formula for the date is the following: formatDateTime(addDays('1899-12-30',int(item()?['DATE_BRUT'])),'yyyy-MM-dd')

 

This error I get (actually the end of it):

"@formatDateTime(addDays('1899-12-30',int(item()?['DATE_BRUT'])),'yyyy-MM-dd')"
}' failed: 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.

The error is the same if I use DATE (date format) instead of DATE_BRUT (text format).

 

I don't think the rest of the flow is relevant because I'm stuck just above, but here it is

PierrickBIT_3-1675104838330.png

The "compose" step is used to make a beautiful table, like Reza Dorrani showed in his video I linked earlier.

 

That may be the ultimate question about this issue, so if you please help me you will be remembered as a true hero.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Next thing to check - are the dates filled in for all your rows, or are some of them blank? If some of them are blank, then you would need to check first before using the formatDateTime expression. See example below:

 

if(empty(item()?['DATE']), null, formatDateTime(item()?['DATE'],'yyyy-MM-dd'))

----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

View solution in original post

8 REPLIES 8
grantjenkins
Super User
Super User

When you set your List items present in a table to ISO8601, what format do the dates come back as? It should come back as standard ISO format. To check, click on Click to download (see screenshot below) on your List rows present in a table and it will show all the raw data in a new window. You can press CTRL+F then search for your date fields to see the actual values. If they are coming back as ISO format (yyyy-MM-dd) then you don't need to use the expression to convert. However, if still coming back as a serial date (44953 for example) then your expression should work.

 

grantjenkins_0-1675132693495.png

 

If you've set to ISO8601 and the dates are coming back in the format yyyy-MM-dd, then your expression would throw an error, which might be what's happening here.

 


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

Thanks for your time Grant

 

You are right, when I set the list format to ISO8601, the date turns to something like: 

PierrickBIT_0-1675151942477.png


That aint that far to good but the timestamp after the day is useless.

That is the reason why I adapted the formula to get rid of the correction based on 01/01/1900 trick.

The new formula is: formatDateTime(item()?['DATE'],'yyyy-MM-dd')

But an error occurs too!

"Date": "@formatDateTime(item()?['DATE'],'yyyy-MM-dd')"
}' failed: 'In function 'formatDateTime', the value provided for date time string '' was not valid. The datetime string must match ISO 8601 format.'. 

When you click on Click to download and view all the data, can you check to see the name of the column? In your expression your using 'DATE', but maybe that's not the actual internal name - it will be whatever you see in the output. Your expression looks fine, so assuming this might be the issue.

 

//Need to validate the name of your column

formatDateTime(item()?['INTERNAL_NAME_OF_YOUR_COLUMN'],'yyyy-MM-dd')

 


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

This is an extraction of the output. See at the end "DATE" field

{"statusCode":200,"headers":{"Pragma":"no-cache","Transfer-Encoding":"chunked","Vary":"Accept-Encoding","x-ms-request-id":"6784170a-3b06-4d45-989e-5ec5aa7c996e;a61b6f34-ceac-4316-a99c-2b63e8cae97d;3a9734e2-e5bf-421e-a3f4-dfd41a03b8cf;1908d1d0-d04a-470a-914c-6fb63469de61","OData-Version":"4.0","Strict-Transport-Security":"max-age=31536000; includeSubDomains","X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"false","x-ms-apihub-obo":"false","Cache-Control":"no-store, no-cache","Date":"Tue, 31 Jan 2023 08:05:44 GMT","Content-Type":"application/json; odata.metadata=minimal; odata.streaming=true","Expires":"-1","Content-Length":"99758"},"body":{"@odata.context":"https://excelonline-we.azconn-we-002.p.azurewebsites.net/$metadata#drives('b%21rZkVczBYwEKlF-nJgwkFAYDBVHCtrX9KmO77I8xCCIFwWBqTwm3eRItxAt6XfkOa')/Files('01U43LYLSS2MJKUE5575C2R3QLV3AFOXT4')/Tables('%7B00000000-000C-0000-FFFF-FFFF00000000%7D')/items","value":[{"@odata.etag":"","ItemInternalId":"59b69bbb-562e-4f9c-9caf-52c1666eaf76","SOMME":"20","TYPE":"virement","DATE":"2023-01-23T00:00:00.000Z","DATE_BRUT":"44949",

 

Next thing to check - are the dates filled in for all your rows, or are some of them blank? If some of them are blank, then you would need to check first before using the formatDateTime expression. See example below:

 

if(empty(item()?['DATE']), null, formatDateTime(item()?['DATE'],'yyyy-MM-dd'))

----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
PierrickBIT
Regular Visitor

My God you are right @grantjenkins ! A few lines of the excel tables are actually empty, THAT is the issue in the first place!

 

Look at this ugly thing that comes out HTML table in the email (I had to seriously zoom out) :

PierrickBIT_0-1675165349806.png

 

Man, your parents should have named you Great, not Grant.

 

Well, I will gently smash this Accept as a solution button and send you all my love.

 

BONUS of the most annoying client ever:

 

But, could'nt that flow be like .. smarter? I mean it would be awesome if I had the opportunity to filter every empty line of the original excel table within the excel action, right?  

I found this : Solved: Re: Ignore blank rows using ODATA filter - List Ro... - Power Platform Community (microsoft....

which obviously add a filter action to the flow

 

Wouldn't that be more efficient to use the filter ODATA inside excel online action instead?

 

Glad it got sorted 🙂

 

Using the Filter array would be an option if you were happy to completely exclude those rows where the DATE is blank. But as you mentioned, it would be better to just use the Filter Query in List rows present in a table. The Filter Query you would use is:

//Note we are using two single quotes

DATE ne ''

grantjenkins_0-1675167377862.png

 

However, if you still wanted to return those rows to get the other data, and just leave the date blank in your output, then using the expression to check if the date is empty would be the way to go. It looked like you were outputting additional fields such as NOM PRENOM into your HTML table.


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

DATE ne '' ...

what kind of a language is this? Sounds like old roman latin scriptus 🤣


Don't know where that comes from but it works, impressive!

 

You're right, there are far more fields that come with the date (like NOM PRENOM) but none can be empty. That's why your solution is typically what I needed.

 

anyway MANY MANY MANY thanks. You've just earned the status of Sir @grantjenkins . Admins, give that man a cookie!

 

Cannot wait to ask you another tricky question 😅.

Best regards

Helpful resources

Announcements

Power Platform Connections - Episode 6 | March 23, 2023

Episode Six of Power Platform Connections sees David Warner and Hugo Bernier talk to talk to Business Applications MVP Shane Young, alongside the latest news, product updates, and community blogs.    Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show!        Show schedule in this episode:  0:00 Cold Open 00:24 Show Intro 01:02 Shane Young Interview 22:00 Blogs & Articles 22:20 Integrate FullCalendar.io with Power Pages 23:50 Text Data 25:15 Zero to Hero Power Apps Saga 25:44 Parent Hub Association 26:33 Using Custom Values for OneNote Power Automate References​ 28:04 ​Dynamics Power Israel 28:44 Create Beautiful Canvas Apps in Dataverse for Teams ​ 30:36 Outro & Bloopers  Check out the blogs and articles featured in this week’s episode:   https://francomusso.com/integrate-fullcalendar-io-with-power-pages-from-json-basics-to-advanced-outp... @crmbizcoach https://yerawizardcat.com/text/ @YerAWizardCat www.fromzerotoheroes.com/mentorship ​ @thevictordantas https://www.expiscornovus.com/2023/03/16/parent-hub-association/ ​ @Expiscornovus https://lindsaytshelton.com/2023/03/15/the-painful-process-of-custom-values-for-onenote-power-automa... @lshelton_Tech https://never-stop-learning.de/create-beautiful-canvas-apps-in-dataverse-for-teams/ @MMe2K    Action requested: Feel free to provide feedback on how we can make our community more inclusive and diverse.  This episode premiered live on our YouTube at 12pm PST on Thursday 23rd March 2023.  Video series available at Power Platform Community YouTube channel.    Upcoming events:  Business Applications Launch – April 4th – Free and Virtual! M365 Conference - May 1-5th - Las Vegas Power Apps Developers Summit – May 19-20th - London European Power Platform conference – Jun. 20-22nd - Dublin Microsoft Power Platform Conference – Oct. 3-5th - Las Vegas  Join our Communities:  Power Apps Community Power Automate Community Power Virtual Agents Community Power Pages Community  If you’d like to hear from a specific community member in an upcoming recording and/or have specific questions for the Power Platform Connections team, please let us know. We will do our best to address all your requests or questions.   

Announcing | Super Users - 2023 Season 1

Super Users – 2023 Season 1    We are excited to kick off the Power Users Super User Program for 2023 - Season 1.  The Power Platform Super Users have done an amazing job in keeping the Power Platform communities helpful, accurate and responsive. We would like to send these amazing folks a big THANK YOU for their efforts.      Super User Season 1 | Contributions July 1, 2022 – December 31, 2022  Super User Season 2 | Contributions January 1, 2023 – June 30, 2023    Curious what a Super User is? Super Users are especially active community members who are eager to help others with their community questions. There are 2 Super User seasons in a year, and we monitor the community for new potential Super Users at the end of each season. Super Users are recognized in the community with both a rank name and icon next to their username, and a seasonal badge on their profile.    Power Apps  Power Automate  Power Virtual Agents  Power Pages  Pstork1*  Pstork1*  Pstork1*  OliverRodrigues  BCBuizer  Expiscornovus*  Expiscornovus*  ragavanrajan  AhmedSalih  grantjenkins  renatoromao    Mira_Ghaly*  Mira_Ghaly*      Sundeep_Malik*  Sundeep_Malik*      SudeepGhatakNZ*  SudeepGhatakNZ*      StretchFredrik*  StretchFredrik*      365-Assist*  365-Assist*      cha_cha  ekarim2020      timl  Hardesh15      iAm_ManCat  annajhaveri      SebS  Rhiassuring      LaurensM  abm      TheRobRush  Ankesh_49      WiZey  lbendlin      Nogueira1306  Kaif_Siddique      victorcp  RobElliott      dpoggemann  srduval      SBax  CFernandes      Roverandom  schwibach      Akser  CraigStewart      PowerRanger  MichaelAnnis      subsguts  David_MA      EricRegnier  edgonzales      zmansuri  GeorgiosG      ChrisPiasecki  ryule      AmDev  fchopo      phipps0218  tom_riha      theapurva  takolota     Akash17  momlo     BCLS776  Shuvam-rpa     rampprakash   ScottShearer     Rusk   ChristianAbata     cchannon   Koen5     a33ik        AaronKnox        Matren        Alex_10        Jeff_Thorpe        poweractivate        Ramole        DianaBirkelbach        DavidZoon        AJ_Z        PriyankaGeethik        BrianS        StalinPonnusamy        HamidBee        CNT        Anonymous_Hippo        Anchov        KeithAtherton        alaabitar        Tolu_Victor        KRider        sperry1625        IPC_ahaas      zuurg     rubin_boer     cwebb365       If an * is at the end of a user's name this means they are a Multi Super User, in more than one community. Please note this is not the final list, as we are pending a few acceptances.  Once they are received the list will be updated. 

Microsoft Power Platform | March 2023 Newsletter

Welcome to our March 2023 Newsletter, where we'll be highlighting the great work of our members within our Biz Apps communities, alongside the latest news, video releases, and upcoming events. If you're new to the community, be sure to subscribe to the News & Announcements and stay up to date with the latest news from our ever-growing membership network who find real "Power in the Community".        LATEST NEWS Power Platform Connections Check out Episode Five of Power Platform Connections, as David Warner II and Hugo Bernier chat with #PowerAutomate Vice President, Stephen Siciliano, alongside reviewing out the great work of Vesa Juvonen, Waldek Mastykarz, Maximilian Müller, Kristine Kolodziejski, Danish Naglekar, Cat Schneider, Victor Dantas, and many more.       Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show!   Did you miss an episode?  Catch up now in the Community Connections Galleries Power Apps, Power Automate, Power Virtual Agents, Power Pages     Power Platform leading a new era of AI-generated low-code development.   **HOT OFF THE PRESS** Fantastic piece here by Charles Lamanna on how we're reinventing software development with Copilot in Power Platform to help you can build apps, flows, and bots with just a simple description! Click here to see the Product Blog         Copilot for Power Apps - Power CAT Live To follow on from Charles' blog, check out #PowerCATLive as Phil Topness gives Clay Wesener Wesner a tour of the capabilities of Copilot in Power Apps.           UPCOMING EVENTS   Modern Workplace Conference Check out the Power Platform and Microsoft 365 Modern Workplace Conference that returns face-to-face at the Espace St Martin in Paris on 27-28th March. The #MWCP23 will feature a wide range of expert speakers, including Nadia Yahiaoui, Amanda Sterner, Pierre-Henri, Chirag Patel, Chris Hoard, Edyta Gorzoń, Erika Beaumier, Estelle Auberix, Femke Cornelissen, Frank POIREAU, Gaëlle Moreau, Gilles Pommier, Ilya Fainberg, Julie Ecolivet, Mai-Lynn Lien, Marijn Somers, Merethe Stave, Nikki Chapple, Patrick Guimonet, Penda Sow, Pieter Op De Beéck, Rémi Riche, Robin Doudoux, Stéphanie Delcroix, Yves Habersaat and many more.  Click here to find out more and register today!     Business Applications Launch 2023 Join us on Tuesday 4th April 2023 for an in-depth look into the latest updates across Microsoft Power Platform and Microsoft Dynamics 365 that are helping businesses overcome their biggest challenges today. Find out about new features, capabilities, and best practices for connecting data to deliver exceptional customer experiences, collaborating and creating using AI-powered capabilities, driving productivity with automation, and building future growth with today’s leading technology. Click Here to Register Today!       Power Platform Conference 2023 We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5th, 2023! But first, let's take a look below at some fun moments from MPPC 2022 in Orlando Florida. 2023 sees guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, and many more taking part, so why not click the link below to register for the #PowerPlatformConf today! Vegas, baby! Click Here to Register Today!      COMMUNITY HIGHLIGHTS Check out our top Super and Community Users reaching new levels!  These hardworking members are posting, answering questions, kudos, and providing top solutions in their communities.   Power Apps:  Super Users:  @WarrenBelz  |  @iAm_ManCat  Community Users: @LaurensM | @Rusk | @RJM07    Power Automate:   Super Users: @abm  | @Expiscornovus | @RobElliott  Community Users:  @grantjenkins | @Chriddle    Power Virtual Agents:   Super Users: @Expiscornovus | @Pstork1  Community Users: @MisterBates | @Jupyter123 | Kunal K   Power Pages: Super Users:  @OliverRodriguesOliverRodrigues | @Mira_Ghaly  Community Users: @FubarFubar | @ianwukianwuk  LATEST PRODUCT BLOG ARTICLES  Power Apps Community Blog  Power Automate Community Blog  Power Virtual Agents Community Blog  Power Pages Community Blog  Check out 'Using the Community' for more helpful tips and information:  Power Apps, Power Automate, Power Virtual Agents, Power Pages 

Register now for the Business Applications Launch Event | Tuesday, April 4, 2023

Join us for an in-depth look into the latest updates across Microsoft Dynamics 365 and Microsoft Power Platform that are helping businesses overcome their biggest challenges today.   Find out about new features, capabilities, and best practices for connecting data to deliver exceptional customer experiences, collaborating, and creating using AI-powered capabilities, driving productivity with automation—and building towards future growth with today’s leading technology.   Microsoft leaders and experts will guide you through the full 2023 release wave 1 and how these advancements will help you: Expand visibility, reduce time, and enhance creativity in your departments and teams with unified, AI-powered capabilities.Empower your employees to focus on revenue-generating tasks while automating repetitive tasks.Connect people, data, and processes across your organization with modern collaboration tools.Innovate without limits using the latest in low-code development, including new GPT-powered capabilities.    Click Here to Register Today!    

Check out the new Power Platform Communities Front Door Experience!

We are excited to share the ‘Power Platform Communities Front Door’ experience with you!   Front Door brings together content from all the Power Platform communities into a single place for our community members, customers and low-code, no-code enthusiasts to learn, share and engage with peers, advocates, community program managers and our product team members. There are a host of features and new capabilities now available on Power Platform Communities Front Door to make content more discoverable for all power product community users which includes ForumsUser GroupsEventsCommunity highlightsCommunity by numbersLinks to all communities Users can see top discussions from across all the Power Platform communities and easily navigate to the latest or trending posts for further interaction. Additionally, they can filter to individual products as well.   Users can filter and browse the user group events from all power platform products with feature parity to existing community user group experience and added filtering capabilities.     Users can now explore user groups on the Power Platform Front Door landing page with capability to view all products in Power Platform.      Explore Power Platform Communities Front Door today. Visit Power Platform Community Front door to easily navigate to the different product communities, view a roll up of user groups, events and forums.

Microsoft Power Platform Conference | Registration Open | Oct. 3-5 2023

We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5 2023! But first, let's take a look back at some fun moments and the best community in tech from MPPC 2022 in Orlando, Florida.   Featuring guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, Stephen Siciliano, Hugo Bernier and many more.   Register today: https://www.powerplatformconf.com/   

Top Solution Authors
Users online (1,626)