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 / Need To Extract Days f...
Power Automate
Unanswered

Need To Extract Days from the derived Date format.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a flow to get query results(workitems) from Azure devops, i am calculating the age of the bug with below function. 

Sukesh_Reddy_0-1714642823930.png

dateDifference(item()?['System.CreatedDate'], utcNow())
output: 
{
    "Age""28.10:24:11.9458506"
  },
 
i want to extract days from the above output i.e 28.
 
Can anyone help me with this.
 
Thanks in advance.
Categories:
I have the same question (0)
  • rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at

    Hi @Sukesh_Reddy ,

     

    You can use an expression like this: first(split(variables('timespan_days'), '.')), just replacing the text in red for your actual timespan content extracted from dateDifference(). this expression will give you the output as string, so you may also want to encapsulate it with an int() expression to convert it as a number.

     

    I'm also sharing an article that I recently wrote about this topic, bringing some other scenarios on how to extract data from timespans: http://digitalmill.net/2024/04/16/extracting-days-and-time-from-timespans-in-power-automate/ 

     

    Let me know if it works for you or if you need any additional help!

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/ 
    https://www.linkedin.com/in/raphael-haus-zaneti/ 

     

  • Sukesh_Reddy Profile Picture
    Microsoft Employee on at

    Thank you @rzaneti ,

    Your suggestion helped me to figure out a solution for my blocker.

    in my scenario i am retrieving multiple (around 200) work items from query, so i used apply for each in my case.

    initialized the variable outside the loop and set the variable inside the loop.

    Sukesh_Reddy_0-1714698521968.png

     

     

  • Sukesh_Reddy Profile Picture
    Microsoft Employee on at

    @rzaneti ,

     

    i am able to get the correct output but unable to apply to my table.

    Sukesh_Reddy_0-1714708561290.png

    i want the above output to be displayed in column in a table one by one.

     

    example output:

    Sukesh_Reddy_0-1714709008959.png

     

     

     

  • rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at

    Hi @Sukesh_Reddy ,

     

    I'm glad that the days quantity issue is solved! 

     

    About the table one, it looks like you are passing a string as input to your "Create a HTML table" action, while an array of objects is expected. I'm sharing a blog post about objects, for the users that reach this topic and never worked with this data type before.

     

    Just to confirm: you want to return an HTML table with a single column (age of the bug in days), right? If this is the case, start by creating an array variable, where the array of objects will be stored:

    rzaneti_2-1714736232673.png

     

    For this example, I will create an additional array variable (you don't need to), just to simulate the dates from where we will extract the days quantity for each of your bugs:

    rzaneti_3-1714736466376.png

     

    Then, inside the apply to each, create an "Compose" action to craft you object. It is simple: you just need to add a "days" key, and set the expression to extract the days from timespan as value:

    rzaneti_4-1714736599361.png

    This is the final input: {"days": [expression]}. Feel free to change the key name for something more meaningful.

     

    The following step is to add an "Append to array variable" action, passing your compose as input:

    rzaneti_5-1714736773631.png

     

    Now your array of objects is ready, and we can generate the table. Out of the loop, add a "Create HTML table" action, passing your array variable as input. If you choose the "automatic" option for the columns dropdown, the column name will match to the objects key. If you wish, it is possible to change the name of the column by choosing "custom" in the dropdown, but you will need to pass the expression item()[key_name] in the right input. For this example, we are using both approaches:

    rzaneti_7-1714737302953.png

     

     

    And these are the outputs for each approach:

    rzaneti_8-1714737877109.png

    rzaneti_9-1714737887750.png

     

    Let me know if it works for you or if you need any additional help!

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/ 
    https://www.linkedin.com/in/raphael-haus-zaneti/ 

     

     

  • Sukesh_Reddy Profile Picture
    Microsoft Employee on at

    @rzaneti ,

     

    Clarification:

    i want all these columns in my table along with Days.

    Sukesh_Reddy_0-1714834720467.png

    so, i tried to do it as per your suggestion.

    Sukesh_Reddy_1-1714834797560.png

    Note: Above solution works but,

    When i tried to add ID, AssignedTo, Title, Days it directly picks the loop and fails with the below error.

    Sukesh_Reddy_2-1714834817357.png

     

    Sukesh_Reddy_3-1714834831700.png

     

     

  • Verified answer
    rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at

    Hi @Sukesh_Reddy ,

     

    The loop is generated because you are selecting columns from both the array variable and the "Get query results".

     

    You can start by changing the "From" input in the "Create HTML table", keeping the "value" property only. When mapping the columns, add the expression to extract the days (first....) to the cell on the right of "Age". Currently, this formula is allocated in your "Compose" action. 

     

    As you need other columns in addition to the age, the "Compose" approach may not help you. 

     

    Let me know if it works for you or if you need any additional help!

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/ 
    https://www.linkedin.com/in/raphael-haus-zaneti/ 

  • Verified answer
    Sukesh_Reddy Profile Picture
    Microsoft Employee on at

    @rzaneti ,

     

    Thank you for the help @rzaneti this worked perfectly fine.

     

    brief:

    Adding this expression in the Create_html_table step me achieve the desired output.

    first(split(dateDifference(item()?['System.CreatedDate'], utcNow()), '.'))
     
    Sukesh_Reddy_0-1715048464172.png

     

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