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?
this is my flow to get the total days
Thank you.
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
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)
The output will look like below.