web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Converting Date to Int...
Power Automate
Unanswered

Converting Date to Integer Value

(0) ShareShare
ReportReport
Posted on by

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!

Categories:
I have the same question (0)
  • efialttes Profile Picture
    14,756 on at

    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!

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    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!

  • Community Power Platform Member Profile Picture
    on at

    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?

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    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!

  • Community Power Platform Member Profile Picture
    on at

    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!
     
     
  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    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. 
  • Community Power Platform Member Profile Picture
    on at

    I finally got the answer and I feel happy now to explain. I struggled a lot to convert from normal date (yyyy-MM-dd) to a integer date.

     

    Step 1:

    Get the desired date you want to convert into 'yyy-MM-dd' format.

    I was working with current_date. So, I created a string variable named "current_date" and gave it a value using the expression :

    formatDatetimeValue(utcNow(), 'yyyy-MM-dd')

    Step 2:

    Converting the above string variable into an integral date.

    add(div(sub(ticks(<insert_date>),ticks('1900-01-01')),864000000000),2)

     

  • ninjaryder1st Profile Picture
    234 on at

    Hi @Anonymous ,

     

    What power automate "actions" did you use to create the date string in step 1 and convert that string in step 2 above? 

    Was this a pre-existing Dynamic Content action, or an "Expression"?   

    If it was the f(x) type expression, what 'action' did you place the expression within?   Was it "initialize variable" or "compose"?     

     

    I'm trying to do this, but having trouble finding the correct action to use for step 1 and 2 you mentioned.  Thanks!

    I put the dynamic content for my "intake date" into the expression and it throws errors. 

     

    ninjaryder1st_0-1634318046735.png

    ninjaryder1st_1-1634318079004.png

     

  • JulianaD Profile Picture
    25 on at

    This is great, thanks! I got it to work for me using this formula (I want to store today's date as an integer in my sharepoint list): 

     

    add(div(sub(ticks(convertTimeZone(utcNow(),'UTC','Mountain Standard Time','MM/dd/yyyy')),ticks('1900-01-01')),864000000000),2)

     

    Juliana Donkersgoed

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard