cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted
Frequent Visitor

Re: Converting Date to Integer Value

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
Highlighted
Dual Super User III
Dual Super User III

Re: Converting Date to Integer Value

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!



Highlighted
Dual Super User III
Dual Super User III

Re: Converting Date to Integer Value

Hi @mattroed 

 

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!

Highlighted
Frequent Visitor

Re: Converting Date to Integer Value

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?

Highlighted
Dual Super User III
Dual Super User III

Re: Converting Date to Integer Value

Hi @mattroed 

 

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!

Highlighted
Frequent Visitor

Re: Converting Date to Integer Value

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!
 
 
Highlighted
Frequent Visitor

Re: Converting Date to Integer Value

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
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (3,479)