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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Parse a date range int...
Power Automate
Answered

Parse a date range into individual years + count days

(0) ShareShare
ReportReport
Posted on by 48

I am attempting to create a flow, where:

 

  • By getting a date range, I would add rows in a subgrid (1 row = 1 years)
  • I will count the days in the individual years as some years might not be a whole calendar year

 

I have seen many examples and explanations for SharePoint and Canvas Apps but unable to find how to approach this in a Cloud Flow

 

YEARS.png

Thank you for any suggestions you might have

Categories:
  • SanmeshG Profile Picture
    1,956 Moderator on at

    Hi @FaroukM ,

    To add Year, Months , Days to a date please use the below formula. 1 is the value that I have added in all three formulas.

    To Add year/(s) to a date , please use the below formula.

    addToTime(utcNow(),1,'year')

    To find Month/(s) , please use the below formula.

    addToTime(utcNow(),1,'Month')

    To add Day/(s) to a date please use the below

    addToTime(utcNow(),1,'Day')

    formula.

     

    To find the number of days (Date Difference) between two days use the below formula.

    div(sub(ticks(outputs('Add_1_Year_to_a_Date')),ticks(utcNow())),864000000000)

    If this helps , please give it a thumbs up and accept this as a solution.

    Thanks,

    Sanmesh

  • Verified answer
    Chriddle Profile Picture
    8,729 Super User 2026 Season 2 on at

    function dateDifference() can do that for you

     

    Chriddle_0-1687447034183.png

     

    Peek code of the select:

     

     

    {
     "inputs": {
     "from": "@outputs('Compose')",
     "select": {
     "Year": "@split(item()['from'], '-')[0]",
     "From": "@formatDateTime(item()['from'], 'dd.MM.yyyy')",
     "To": "@formatDateTime(item()['to'], 'dd.MM.yyyy')",
     "Days": "@split(dateDifference(item()['from'], item()['to']), '.')[0]"
     }
     }
    }

     

     

     

     

    Output table:

    Chriddle_1-1687447271025.png

     

  • F.Mogheth Profile Picture
    48 on at

    Appreciate the reply and its spot on!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 289

#2
11manish Profile Picture

11manish 282 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 119

Last 30 days Overall leaderboard