web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Display Current Year
Power Apps
Unanswered

Display Current Year

(1) ShareShare
ReportReport
Posted on by 76

I have a model driven app with a fairly simple request that I can't figure out how to implement without using Power Automate, which is out of scope for this app

 

I want to dynamically determine the current year when a record is created and save it as a field

 

If that's not possible, I just want to be able to display the current year on a form

 

Am I missing something very obvious or is this much harder than it sounds?

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @Spikyface :

      I'm afraid your request will not be fulfilled.I considered Create a Business rule or Add a Caculation filed.It is very easy to get the current time, but the current year cannot be obtained.

      The only way I can think of at the moment is to insert a canvas app in a form and then use Year(New()) to display the current year in this canvas app.

      If you want to display the current year directly in the form, I suggest you to post your ideal on the ideal forum.

    Best Regards,

    Bof

  • AU-22040756-0 Profile Picture
    76 on at

    Thanks for confirming this @v-bofeng-msft, unfortunately embedding a Canvas app into the form to do this is seems too much for this purpose

     

    I did some experimenting around with a calculated field that uses the DIFFINYEARS() function but couldn't work out how to get it to return the current year.

     

    Even then the field would always show the current year, even for older records so it seems like a fudge.

  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @Spikyface :

      I also considered using the DIFFINYEARS() function.

      The calculation method is to calculate the number of years between the current date and a specific date, and then you can know the current year. But it’s easy to get the current date, just use Now(), but it’s impossible to enter a specific date, because you cannot enter a date, such as 01/01/2015, as the Date value in a calculated column. Date and DateTime values can only be set or compared using other DateTime columns.

      I think this link will help:

     Define calculated columns in Power Apps - Power Apps | Microsoft Docs

     In addition the last way is to create or edit the form's web resources.This formula for your reference:

     

    function test(executionContext) {
     var formContext = executionContext.getFormContext();
     var date = new Date();
     var year = date.getFullYear();
     formContext.getAttribute("crb5a_thecurrentyear").setValue(year.toString());
    }

     

    2.JPG

     

    1.JPG

      Best Regards,

      Bof

  • lenro Profile Picture
    194 on at

    Hi @Spikyface ,

     

    I would create a variable where you need to put a date and call it VarYear,

    Then put timer , button or whatever which is updating it as often as you need and put a formula to it 
    Text(VarYear,"[$-en-US]yyyy")

    If you don't need to update it , then instead of VarYear, just use Today()

  • KEarley Profile Picture
    276 on at

    Where is the function placed?  Does it go in the application, sharepoint calculated field, or is this some other platform?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard