cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Excel dates turned into integers?

Hello! I'm a fairly new flow user here and I have a flow which needs to extract dates from an excel spreadsheet and email them out. The kicker is that I cannot figure out why flow is importing the data from the spreadsheet as plain numbers instead of as dates even though the cells themselves are formatted as dates for example the date 06/18/12 is being read in as 41078, any advice? thanks in advance for the help!

36 REPLIES 36

Where do you enter this? i have a similar issue, im importing a spread sheet of last logon dates for users into a sharepoint list, the field type in the list is date and it fails every time, if i change the type to text, it imports but as a number. ive tried several google searches, but ive now started getting 

 

One or more fields provided is of type 'Null', a different type is expected.

 

I assume this is because some of the fields are empty so cannot convert them?

Anonymous
Not applicable

@ResRudeBoy Which part are you asking about? It sounds like you may need to add a condition to check for Null. With the spreadsheets I get, I can't ever predict whether the user will have formatted the field as Date or as Text, so I added a simple condition to check for the presence of a forward slash ( / ). If it comes in with slashes, I know it's already a human-readable date and I can just plug it into my SharePoint field. If there are no slashes, I can assume it's coming in as an integer, so I go down a path with Compose actions to turn it back into a readable date.

 

So you add a Compose action and in the Inputs field, go to Expression in the Dynamic Content pop-up. Type in:

 

if(empty(items('Apply_to_each')?['DateFieldGoesHere']),'',addDays('1899-12-30',int(items('Apply_to_each')?['DateFieldGoesHere']),'MM/dd/yyyy'))

 

...and make sure you click UPDATE to add it to the Inputs field of your compose action. In my example, I have two dates I'm trying to deal with.

 

date-compose.PNG

Hi, where would i enter addDays('1900-01-01',int(items('_')?['Date'])) in the flow or in the column formatting for the list? *EDIT Please ignore this i didnt see the reply above.

HI, that sort of worked. now the empty values are going in as 01/01/1601 which is ok i can work with that. but when it gets to cells with a value the flow fails with 

 

InvalidTemplate. Unable to process template language expressions in action 'Update_LastLogon' inputs at line '1' and column '2257': 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'

 

Im wondering, the data that extracts from AD shows as this for example 3/23/2020 1:50:51 PM but the data from excel is

44012.3886816898 could it be because the formula you suggested only accounts for the date up to the decimal point?
 
Thanks for your help on this, its killing me trying to understand something which seems so simple....

I think I am following, but I still cannot get it to work.  

 

I have an excel file with a table.  The table has a column "Date of Service" and the date is formatted MM/dd/yyyy.  There is currently only one record I am testing with.  I control this file, so I don't really need to have the "if" statement, but I can't get it to work without it.  

 

So I created the Compose step to create the Date of Service as a Date.  I put it inside my "Apply to Each".  I clicked into the INPUT field, then clicked on EXPRESSION, then pasted 

 

if(empty(items('Apply_to_each')?['Datex0020_ofx0020_Service']),'',addDays('1899-12-30',int(items('Apply_to_each')?['Datex0020_ofx0020_Service']),'MM/dd/yyyy'))

 

I then pick up the output from this step in my "Date of Service" field when I do my "Create Item" step into SharePoint. 

 

When I run it, it succeeds, but the "Date of Service" is blank.  It shows both blank inputs and outputs when I check it.

 

I cannot seem to add a screen print here.  PowerAutomateLayout

 

ive cheated a little, ive changed the output of the powershell script of the lastlogondate to format in MM/dd/yyyy this now seems to import with no extra conditions. Thanks for helping.

@ResRudeBoyI would do that if I knew how.  Can that be done in Power Automate? 

Sorry, i dont know, i found the input of date formats have to be MM/dd/yyyy (i cant change the local settings as im not an admin)

 

So i adjusted my script which outputs my data from AD to bring the date format out in that format 

 

@{Name="LastLogonDate";Expression={$_.LastLogonDate.ToString('MM/dd/yyyy')}} is what i used in my powershell export, then in sharepoint i just changed the input field to date format and it imports fine. no calculations on the field or in my flow.

For those struggling with this (and specifically with just a plain time value), here is a expression that can be used to convert the float value into a time string. The extra conditional is needed to handle the case when there is no value. It comes across as a " " value and the subsequent number casts DO NOT like empty values.

 

I imagine this could be adapted to work for full dates as well.

 

if(equals(trim(item()?['Hours Weekday Open']), ''), null, formatDateTime(addToTime('1970-01-01T00:00:00Z', int(string(mul(float(item()?['Hours Weekday Open']), 86400))), 'Second'), 'HH:mm tt'))

 

Where are we supposed to add this expression? when I try to set Variable for this I am not able to select the string in formula

Anonymous
Not applicable

@Nanig 
You have to put that expression into a Compose action and then use the Output of that action as the value you save to SharePoint. 

For me, Step 1 was to set a variable with the value from Excel. This will automatically go into an Apply to Each loop:

set var date.PNG

 

If this value is formatted as a DATE in Excel, Flow will see it as an integer. So Step 2 is to check for the presence of a forward slash ( / 😞

date-slash.PNG

 

If the condition detects a forward slash, then this date value is formatted as text and I can write it to SharePoint directly as-is. BUT if this condition comes back as false, I know that the value is a Date in Excel, that Flow now sees it as an integer, and I need to use a Compose action to turn that integer back into a human-readable date:
compose-date.PNG

I want to write the Output of this Compose action to a SharePoint date column. As you can see, some values are simple text or numbers that I can save to SharePoint directly from Excel (the green boxes below -- this is all using the Create Item action for SharePoint), but for the Work Date field, I want to plug in the Outputs of the Compose action.

compose-outputs.png

 

Does that help at all?

I hope this is not consider off-topic

I have made a flow to send certain email that in the body would contain a date ( from the column 'Planned date' in an online excel sheet )

In the excel, the date in the following format 08 February 2021 ( in the formula bar it's showing as 2/8/2021 )

first iteration of the flow on 20th of  Jan: The email showed the date as: 2021-02-08T00:00:00.000Z   // dynamic content - Planned Date
second iteration of the flow on 20th of  Jan with formatting formula format Date Time :  2021-02-08 (easy fix)

3rd iteration on the 22nd  of Jan (presenting to manager): error - format Date Time formula not working. Checked without formula, just the dynamic content -> 44235   

 

Thus, me writing on the forum right now.

Is there a logical explanation for this?

ericonline
Community Champion
Community Champion

Grrrr.... this should be easier. 

I'm trying to calculate the date and time separately then concatenate them at the end. Calculating the Time is giving me troubles. 

Can anyone see what I'm missing?

Excel sheet with date times that LOOK like this: 

5/4/2021 6:51:27 PM

 

When imported to Flow, they LOOK like this:

44320.7857291667

 

I'm trying to convert to a friendly format for performing calculations (greater than date, etc.). Can't seem to get the time right. 

 

For each row in the Excel sheet: 

 

1. Split the incoming decimal using: 

 

 

first(
  split(
    items('Apply_to_each')?['dateTimeStamp'],
    '.'
  )
)

 

 

2. Use first part of split to calculate date: (This works)

 

 

formatDateTime(
    addDays(
        '1899-12-30', 
        int(
            outputs('split_action')
        )
    ),
    'MM/dd/yyyy'
)

 

 

- Results in: 05/04/2021

 

3.  Split incoming decimal, take last part:

 

 

last(
  split(
    items('Apply_to_each')?['dateTimeStamp'],
    '.'
  )
)

 

 

4. Use last part of split to calculate time (This does NOT work):

 

 

formatDateTime(
    addToTime(
        '1970-01-01T00:00:00Z', 
        int(
            string(
                div(
                    float(
                        outputs('split_action_2')    
                    ),
                    86400
                )
            )
        ),
        'Second'
    ),
    'HH:mm:ss tt'
)

 

 

 - Results in: 19:14:08 PM

ericonline
Community Champion
Community Champion

Finally figured this out...

formatDateTime(
    addToTime(
        '00:00:00', 
        int(
            formatNumber(
                mul(
                    86400, 
                    float(
                        concat(
                            '.', 
                            outputs('LAST_split_excel_date')
                        )
                    )
                ),
                'N0'
            )
        ),
        'Second'
    ),
    'HH:mm:ss tt'
)

 Theres probably a better way to include the '.' than the hacky concat, but. This works. 

 

Then proceed to: concat the calculated date and time into a string then format. 

 

Wow. What a process to go from Excel's decimal format of date times back to human readable. 

hjaf
Kudo Commander
Kudo Commander

There is a parameter for date time format. I believe this has been introduced after the initial post.
Here you can see the documentation for listing rows, but this parameter is also available for updating and adding rows:
https://docs.microsoft.com/en-us/connectors/excelonlinebusiness/#list-rows-present-in-a-table

The documentation is a bit unclear and should really be improved. But from what i can gather, the values you can choose from in the connector is provides the following code in code view:

 

 

"dateTimeFormat": "ISO 8601"

 

 

 

 

 

"dateTimeFormat": "Serial Number"

 

 

This suggest that only these two options are available, even though you can provide a custom value it is somewhat confusing. When attempting to use a custom ISO 8601 format the error informs about this:

 

 

The API operation 'GetItems' requires the property 'dateTimeFormat' to be set to one of its defined enum values '["Serial Number","ISO 8601"]' but is set to 'YYYY-Www-D'.'.

 

 

Turns out that the documentation is less helpful than the errors. The documentation says nothing about which ISO 8601 format one should use for input if that were the case. However it seems that the default ISO 8601 format "UTC" is used. 
When ISO 8601 is selected the output is:

1986-04-19T13:00:00.000Z

otherwise it returns the serialized value:

 

 

"31521.5416666667"

 

 

 

The same thing is used for adding or updating rows, you can use the built-in time actions in power automate directly without having to deal with the formatting 🙂
ISO 8601 excel inputISO 8601 excel input

ericonline
Community Champion
Community Champion

So after spending 1/2 the day yesterday learning about how to work with the Excel decimal format (and all the date and time calcs that come along), then teaching a class on it today, one of my colleagues pointed out the new-ish DateTimeFormat option in List All Rows in Table...

 

At least they didn't point it out WHILE I was teaching the class... that might have been embarrassing... oh wait... yes they did 🙂

 

All good. I'm REAL GOOD at decimal to date / time WDL calcs now. 

 

https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Excel-Date-changes-in-Power-Automa...

 

🌴to 🙂 !

Maybe late for you, but the issue was the variable name 'Completion time' . I suggest to do not use spaces, try with some like 'Completion_time' or 'completionTime'.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,650)