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 Apps / Converting Days into y...
Power Apps
Answered

Converting Days into years

(0) ShareShare
ReportReport
Posted on by 112

Hi, 

 

I have a canvas app I am building. I want the user to be able to select a date that they started at an organization from a date picker. Then I want it to automatically calculate the number of whole years/half years that they have been employed. 

The formula I currently have works but it only calculates whole years, not the half years as well. Any tips? Below is the formula. DatacardValue11 contains the date the user is selecting, TextInput1 contains today's date.

 

With({_start: DateValue(DataCardValue11.SelectedDate), _end: TextInput1.Text},
    Year(_end) - Year(_start) -1 + 
    If(DateDiff(Date(Year(2020), Month(_end), Day(_end)), Date(Year(2020), Month(_start), Day(_start)))>0, 0, 1)
)

Categories:
I have the same question (0)
  • Verified answer
    SebS Profile Picture
    4,803 Super User 2026 Season 1 on at

    @kat7777777 

     

    Try this one just replace Controls to fit them to Yours

     

    With({_start: DateValue(DatePickerCanvas1.SelectedDate), _end: DateValue(TextInputCanvas1.Value)},
     Year(_end) - Year(_start) - 1 + 
     If(DateDiff(Date(Year(2020), Month(_end), Day(_end)), Date(Year(2020), Month(_start), Day(_start))) > 0, 0, 1) +
     If(Mod(DateDiff(_start, _end, TimeUnit.Days), 365) >= 182.5, 0.5, 0)
    )

     

  • SebS Profile Picture
    4,803 Super User 2026 Season 1 on at

    @kat7777777 

     

    But I switched also _Start with _End

     

    With({_end: DateValue(DatePickerCanvas1.SelectedDate), _start: DateValue(TextInputCanvas1.Value)},
     Year(_end) - Year(_start) - 1 + 
     If(DateDiff(Date(Year(2020), Month(_end), Day(_end)), Date(Year(2020), Month(_start), Day(_start))) > 0, 0, 1) +
     If(Mod(DateDiff(_start, _end, TimeUnit.Days), 365) >= 182.5, 0.5, 0)
    )

     

    SebS_0-1715266304341.png

     

  • kat7777777 Profile Picture
    112 on at

    This works! Thank you for your help!!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard