Good Afternoon Community,
I have a challenge. I am doing a employment experience calculator. Testing my abilities in PowerApps. In the calculator I am trying to calculate the years, months and days difference for multiple period. Now figuring out the DateDiff in years, months and days is between the start and end days is easy. I did that but here is the scenerio.
Lets say I have a total of 1700 days. That is 4 years, 7 months and 21 days which I am able to replicate in excel using the DatedIf function. In PowerApps, I want that same result in txtTotalTimeElapsed which is highlighted below. I have tried taking the value of each periods DateDiff(input1,input2,Days) then divide it by 365 to get the years and by 30 days to get the months but the calculations are not adding up. I feel like a concat function would be the solution but I was wrong. Any help would be appreciated.
Side question, I am not using a form but I would like the user to be able to print the data as a PDF in a specific format.
I
Solved! Go to Solution.
Hi @DataGuy85,
Try as below:
With(
{
totalDays: DateDiff(
DatePicker2.SelectedDate,//statrt date
DatePicker3.SelectedDate,//end date
Days
) + 1
},
With(
{
totalYears: RoundDown(
totalDays / 365,
0
),
remainingDaysFromYearsRollUp: Mod(
totalDays,
365
)
},
With(
{
MonthsInRemainingDays: RoundDown(
remainingDaysFromYearsRollUp / 30,
0
),
remainingDaysFromMonthsRollUp: Mod(
remainingDaysFromYearsRollUp,
30
)
},
totalYears & " years / " & MonthsInRemainingDays & " months / " & remainingDaysFromMonthsRollUp & " days"
)
)
)
Hi @DataGuy85,
Try as below:
With(
{
totalDays: DateDiff(
DatePicker2.SelectedDate,//statrt date
DatePicker3.SelectedDate,//end date
Days
) + 1
},
With(
{
totalYears: RoundDown(
totalDays / 365,
0
),
remainingDaysFromYearsRollUp: Mod(
totalDays,
365
)
},
With(
{
MonthsInRemainingDays: RoundDown(
remainingDaysFromYearsRollUp / 30,
0
),
remainingDaysFromMonthsRollUp: Mod(
remainingDaysFromYearsRollUp,
30
)
},
totalYears & " years / " & MonthsInRemainingDays & " months / " & remainingDaysFromMonthsRollUp & " days"
)
)
)
Thank you that fixed it.