Categories: Microsoft 365

Read dates from Excel with Power Automate

To read dates from Excel files can be tricky, as Excel only give you the number of days since 1 January 1900.

Dates in Excel

I’ve created myself an Excel table with some dates in it. i will use this example Excel file during the rest of my post.

Read dates from Excel

In general when I read Excel files from SharePoint or OneDrive I would use Microsoft Graph, but for this example I will use the out of the box actions. in both cases Excel will return numbers as we will shortly see.

Using the List rows present in a table action I’m getting all the rows from my excel file. I’m then using a compose action to display the results. this isn’t 100% needed, but it makes debugging just that little bit easier.

Running the above two steps, now gives me tat number that I have been talking about. The 28 October 2020 is day 44132 as you can see below.

Setting a base date

I’m going to set my base date to 2020-10-28, but really you could set this to any date.

Calculating the dates

Now to calculate each date from that number that Excel gives me, I’m using the following steps.

The first step is a Compose action that contains the day from the row in my excel.

In the second compose I’m calculating the number of days since my base day using the following expression, using the sub function.

sub(int(outputs('Date_from_Excel')),
    int(outputs('Base_day_2020_10_28'))
)

Now that we know the number of days since the base date we can calculate the day that we are interested in.

And when we run our flow we will now get the right date returned.

Dates before 1900

Ok, so what happens to dates before 1900.

Well, Excel didn’t exist in 1900.

So, what else would you expect than the actual date being returned?

Sometimes, I just wish that all dates were before 1900.

Share
Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

Recent Posts

Filter Query in SharePoint Get Items in Power Automate

Have you tried the experimental version of Filter query in the SharePoint Get Items action…

2 days ago

3 Ways to add a column to an array in Power Automate

When you have an array in Power Automate and you would like to add a…

6 days ago

Patch any field type in a SharePoint list item using Power Apps

In Power Apps the Patch function is very important when you work with data. In…

1 week ago

Call flows from a model driven app

Wouldn't it be great if you could call flows from a model driven app? Well…

2 weeks ago

Variables or Compose? Consider neither in Power Automate

The question is Variables or Compose actions in Power Automate? Variables Sometimes you need a…

2 weeks ago

Your 1st lesson in Power Apps, in a few easy steps!

1st lessons can be so important when you want to get started with Power apps.…

4 weeks ago
%%footer%%