Forum Discussion
TSimsD
Aug 27, 2020Copper Contributor
Importing dates from Excel into Sharepoint list
Hi, I've tried various forums for answers to this issue but none have succeeded. I have an extensive spreadsheet that I want to import a Sharepoint list. The issue is the date column. irrespective o...
RobElliott
Aug 27, 2020Silver Contributor
TSimsD Excel stores dates as an integer of the number of days since 30 December 1899. So you need to convert that integer to a date before your flow can use the output in SharePoint.
So you will need to add Compose control.
The table in my spreadsheet has a column called Time:
In your flow you'll need to convert that column using an expression in a Compose control:
formatDateTime(addDays('1900-01-01', add(int(items('Apply_to_each')?['Time']),-2)), 'yyyy-MM-dd')
(the way I do it is to use 1900-01-01 for ease of remembering rather than 1899-12-30, then take off 2 days from the result)
You then use the output of that Compose in the relevant field in your SharePoint Create item action.
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.
sumitarjandas
Jan 06, 2021Copper Contributor
Hello RobElliott
I have the same scenario as your solution and have tried your expression in my workflow. However, I am getting an error:
"Unable to process template language expressions in action 'ComposeFormatExcelDate' inputs at line '1' and column '9734': 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'."
Can you assist?
- DairyG1Jul 15, 2021Copper Contributorsumitarjandas - Did you get a resolution on the issue?
"Unable to process template language expressions in action 'ComposeFormatExcelDate' inputs at line '1' and column '9734': 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'."- BusyIntelligenceJul 16, 2021Brass ContributorHi, I've imported lots of Excel files with dates in it.
The expression I use succesfully is:
addDays('1899-12-30',int(items('Apply_to_each')?['Date']),'yyyy-MM-dd')- DairyG1Jul 16, 2021Copper Contributorthanks for the response and yeah that works but its when the date field is blank is what the issue is for me. tried numerous if equal/empty etc, cannot get to work so far
- MJohnson-FisherJan 07, 2021Copper Contributor
sumitarjandas I am getting the same error and really need some help sorting it out. I’ve tried it all!
- stormin_30Jan 08, 2021MVP
Hello All,
I agree with the approach that RobElliott provided.
I've done this before but using a variable (vs compose) to convert and store the Excel date. More details here: Import Excel data into an existing SharePoint List using Power Automate – Norm Young
I hope this helps.
Norm
- TSimsDJan 08, 2021Copper Contributor