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 / Work Anniversary : No ...
Power Automate
Unanswered

Work Anniversary : No of year calculation

(0) ShareShare
ReportReport
Posted on by 6

Hi All 

 

in the sharepoint list for work anniversay year [ No of years ] should be manually maintained or is there any calculation for this feild 

Categories:
  • David_MA Profile Picture
    15,681 Super User 2026 Season 2 on at

    Your question isn't really about Power Automate, but I can give you a solution. You can use JSON formatting of your SharePoint list. You can use this JSON code to return the number of years for a date field.

     

    {
     "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
     "elmType": "div",
     "txtContent": "=if(Number(@currentField) == 0, 'N/A', '@currentField.displayValue' + ' (' + floor((Number(@now) - Number(@currentField)) / (31536000000)) + ' years)')",
     "style": {
     "border": "none",
     "background-color": "transparent",
     "cursor": "pointer"
     }
    }

     

    You cannot use a calculated column, because the calculation is only refreshed when the item is updated. With JSON, it automatically calculates in the view. Here is resource for learning how to format SharePoint views with JSON: Use view formatting to customize SharePoint | Microsoft Learn

     

    The above will return:

    David_MA_0-1714657286003.png

    If someone can figure out how to adjust it to one decimal point, I would appreciate that. I have had no luck so far. But this should work for your use case around work anniversaries.

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 377

#2
11manish Profile Picture

11manish 302 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 130

Last 30 days Overall leaderboard