Skip to main content

Notifications

Power Automate - General Discussion
Answered

calculate years from joining date

(0) ShareShare
ReportReport
Posted on by 997

Hi, I'm trying to get Year of Service based on the Joining Date of an employee. I followed a youtube video and managed to get the total days from the joining date until the present day. I want years instead of days. How to do that? Do I need to divide days into months then years? 

anonymous21_0-1655445224147.png this is my flow to get the total days

 

Thank you.

 

  • syhrh Profile Picture
    syhrh 997 on at
    Re: calculate years from joining date

    @Expiscornovus It works, thank you!

  • Verified answer
    Expiscornovus Profile Picture
    Expiscornovus 31,081 on at
    Re: calculate years from joining date

    Hi @syhrh,


    You could convert the present day and the joiner day to ticks and calculate the difference by using a sub function. You can div the result by 315,360,000,000,000 which is the amount of ticks in a non-leap year:

    https://docs.microsoft.com/en-us/dotnet/api/system.datetimeoffset.addticks?view=net-6.0#remarks

     

    Below is an example of that approach.

     

    1. A SharePoint list with a Joiner Date column

     

    joiner_calc.png

     

    2. The flow with a Get Items and a Select action.

     

    The Years working key uses the following expression as a value:

    div(sub(ticks(utcNow()), ticks(item()?['JoinerDate'])), 315360000000000)

     

    subticks_convertonormalyear.png

     

    The output will look like below.

     

    output_numberofyears.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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,422

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,711

Leaderboard