Handling Excel Dates in Microsoft Flow

Problem

Dealing with dates can be a real pain in the proverbial sometimes … and Microsoft Flow is no exception.

I recently had to bulk load some records from an Excel file into SharePoint Online using Microsoft Flow … you’d be forgiven to think that this would be a trivial task … WRONG!

All was going well until … I encountered date fields in my Excel file … then all hell broke lose!

I was puzzled why Dates in my Excel file were processed by Microsoft Flow as numbers … what the? What’s going on here?

Microsoft Flow and Excel Logos

Solution

The root problem is that Microsoft Flow reads Date columns as Text. It turns out that Excel stores dates in Serial Date format which means that a date like ‘2019-01-10’ will be read as ‘43475’ within Flow. You can read more about how excel handles dates here – http://www.cpearson.com/excel/datetime.htm.

Therefore we need to convert the Number to a Date using the below expression within our flow


// Format
if(empty(<DATE TO CONVERT>,null,addDays('1899-12-30',int(<DATE TO CONVERT>),'yyyy-MM-dd'))

// Example
if(empty(item()?['Start Date'],null,addDays('1899-12-30',int(item()?['Start Date']),'yyyy-MM-dd'))