cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hjaf
Kudo Collector
Kudo Collector

read excel date _and_ time from a datetime column.

I have a table containing a column containing a date AND TIME serialized value (excel magic serialization (tm)).
I am able to get the date using something like addDays('1899-12-30', int(body('Get_row')?['DateAndTime'])). 

 

What is the most elegant and proper way to achieve this?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @hjaf 

 

I have this post here that explains in detail on how to work with date and time type columns of excel in Power Automate: 

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

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

6 REPLIES 6

Hi @hjaf 

 

I have this post here that explains in detail on how to work with date and time type columns of excel in Power Automate: 

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

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

I have tried something similar to this before. but i cannot fathom why i have to do something like this to extract a date from another element in the same ecosystem..


Right now I'm looking at converting the float from excel to a string, split it by '.' and int(first), add a "0." to the last to convert it back into a float and then do someting like:
addSeconds(adddays(<first>), mul(<last>, 86400)))

 

expressions like this feels so wrong.. this is crazy 

oneliner "solution" albeit not at all elegant:

addSeconds(addDays('1899-12-30', int(first(split(string('12345.6789'), '.')))), int(last(split(string(mul(float(concat('0.', last(split(string('12345.6789'), '.')))), 86400)),'.'))))

edit: added ludicrous oneliner expression

Hi @hjaf 

 

Yes. That is an issue actually with the excel connector. The date and time works in that manner for excel and so the workarounds that need to be used for handling that data via power automate. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Ok, so I eventually managed to get this working in a somewhat complicated context. reading multiple files and rows and columns. So it seems atleast. 

 

@yashag2255´s post was helpful, but I needed seconds as well

 

So for anyone ever having to work around this nightmare, here is my ridiculous solution step by step: 
Attention: this solution is not accurate on the second. This has probably to do with rounding done in excel and Power Automate. 
The example below is off with one second. I can perhaps work around this by ignoring decimals during the calculation, mod() or something like that. Suggestions appreciated. 

(this can be pasted into a compose for testing purposes)

Excel serialized time example:
@{string('43902.3547685185')}

Array([Date, Time])
@{split(string(mul(float(concat('0.', last(split(string('43902.3547685185'), '.')))), 86400)), '.')}

Seconds in day: 
@{first(split(string(mul(float(concat('0.', last(split(string('43902.3547685185'), '.')))), 86400)), '.'))}

Days since 1899-12-30:
@{int(first(split(string('43902.3547685185'), '.')))}

Date:
@{addDays('1899-12-30', int(first(split(string('43902.3547685185'), '.'))))}

Hours (today):
@{addSeconds(startOfDay(utcNow()), int(first(split(string(mul(float(concat('0.', last(split(string('43902.3547685185'), '.')) )), 86400)), '.'))))}

DateTime:
@{addSeconds(addDays('1899-12-30', int(first(split(string('43902.3547685185'), '.')))), int(first(split(string(mul(float(concat('0.', last(split(string('43902.3547685185'), '.')) )), 86400)), '.'))))}

DateTimeFormatting:
@{addSeconds(addDays('1899-12-30', int(first(split(string('43902.3547685185'), '.')))), int(first(split(string(mul(float(concat('0.', last(split(string('43902.3547685185'), '.')) )), 86400)), '.'))), 'R')}

DateTime formatting like SharePoint:
@{addSeconds(addDays('1899-12-30', int(first(split(string('43902.3547685185'), '.')))), int(first(split(string(mul(float(concat('0.', last(split(string('43902.3547685185'), '.')) )), 86400)), '.'))), 'yyyy-MM-ddThh:mm:ssZ')}

 Output:

Excel serialized time example:
43902.3547685185

Array([Date, Time])
["30651","9999984"]

Seconds in day: 
30651

Days since 1899-12-30:
43902

Date:
2020-03-12T00:00:00.0000000

Hours (today):
2020-04-13T08:30:51.0000000Z

DateTime:
2020-03-12T08:30:51.0000000

DateTimeFormatting:
Thu, 12 Mar 2020 08:30:51 GMT

DateTime formatting like SharePoint:
2020-03-12T08:30:51Z

 

Next challenge is getting a datetime back into a serialized excel datetime. I will add it here once i find a reliable way.

Hi @hjaf ,

 

I'm afraid that we couldn't get a accurate second time since the date time value we get from the excel table is a converted float.

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

yes i think @yashag2255's solution is the way to go. i need to use ticks like he does to be accurate.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (5,058)