cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Converting Date to Integer Value

I would like to take a date field form a sharepoint list from dynamic content and convert it to its integer value. I am not having any luck finding an expression that will do this. Please help!

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

I got it to work. I had to retype '1900-01-01' on my computer. 

 

So the full solution is first use initialize variable like this

 

concat(last(split(<insert date>,'/')),'-',first(split(<insert date>,'/')),'-',split(<insert date>,'/')?[1])
 
then put this variable into this expression where you want to use it
add(div(sub(ticks(<insert above date>),ticks('1900-01-01')),864000000000),2)
 
And you may have to retype '1900-01-01' on your computer as the copying and pasting did not work. 

View solution in original post

6 REPLIES 6
efialttes
Super User III
Super User III

Hi!

Which integer value? You mean to store it in an Excel?

So assuming you need to store today's date (2020-04-20) I would try with the following

add(div(sub(ticks('2020-04-20'),ticks('1900–01–01')),864000000000),2)

Thanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



yashag2255
Dual Super User II
Dual Super User II

Hi @Anonymous 

 

You can also checkout this article here: https://www.bythedevs.com/post/working-with-date-time-data-of-excel-in-power-automate 

 

where I have explained how to work with Date and Time type columns in Excel but the integer value part for the date and the number value part for the time would just be applicable for any date time formatted string. 

 

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!

Anonymous
Not applicable

I would like to take a date in the format, 'MM/dd/yyyy' and convert it to its numeric value. So for example, 4/27/2020 would convert to 43948. Do you have an expression that could accomplish this?

Hi @Anonymous 

 

You first have to convert the date to yyyy-MM-dd format and only then use one of the formulas mentioned in the posts to convert it to the integer type. 

 

So that could be done using the split expression where you split the current date on '/' 

concat(last(split('MM/dd/yyyy','/')),'-',first(split('MM/dd/yyyy','/')),'-',split('MM/dd/yyyy','/')?[1])

 

The above expression result should be stored in a variable and then use the same in the expresssion shared earlier to get the integer. 

 

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!

Anonymous
Not applicable

Okay I think I am close, but still keep getting error that time is not in iso 8601 format. This is what I have:

 

 
This is used in initialize variable, Presentation Date is pulled from SharePoint. 
Excel Date = concat(last(split(variables('Presentation Date'),'/')),'-',first(split(variables('Presentation Date'),'/')),'-',split(variables('Presentation Date'),'/')?[1])
 
And then this is used to hopefully get the numeric value but keeps failing
add(div(sub(ticks(variables('Excel Date')),ticks('1900–01–01')),864000000000),2)
 
The date I'm testing is May 4th, 2020, so it should return a result of 43955. 
 
Let me know what I should change, thanks!
 
 
Anonymous
Not applicable

I got it to work. I had to retype '1900-01-01' on my computer. 

 

So the full solution is first use initialize variable like this

 

concat(last(split(<insert date>,'/')),'-',first(split(<insert date>,'/')),'-',split(<insert date>,'/')?[1])
 
then put this variable into this expression where you want to use it
add(div(sub(ticks(<insert above date>),ticks('1900-01-01')),864000000000),2)
 
And you may have to retype '1900-01-01' on your computer as the copying and pasting did not work. 

View solution in original post

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

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

Users online (2,157)