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?
Solved! Go to Solution.
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!
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.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Did you know that you could restore a deleted flow? Check out this helpful article.
User | Count |
---|---|
32 | |
31 | |
24 | |
24 | |
20 |
User | Count |
---|---|
59 | |
57 | |
43 | |
37 | |
28 |