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

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Calculate a date in two years

(0) ShareShare
ReportReport
Posted on by

Hi,

 

i work with a document library. As result of a manually triggerd workflow a date in a custom column should be changed to a fixed date in two years automatically.

 

So on whatever date i start the workflow the new date of a specific field (custom column) should Change to 30. June in two years.

 

How i could solve this? Thx

I have the same question (0)
  • RobElliott Profile Picture
    10,276 Super User 2025 Season 2 on at
    Re: Calculate a date in two years

    @Anonymous you just need the SharePoint Update item action for this. After you select the site, enter the document library as a custom value and it will find the columns in your library. Add the date into the relevant field:

    updateItem.png

    Rob
    Los Gallardos
    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

     

     

  • Community Power Platform Member Profile Picture
    on at
    Re: Calculate a date in two years

    Hi Rob,

     

    thx for your feedback, but i already know this Option.

     

    Looking more for the function Formular to replace this date Always to the 30. June plus additional 2 Years from already insered date.
    This could be also a other year than 2022.

  • abm abm Profile Picture
    32,585 Most Valuable Professional on at
    Re: Calculate a date in two years

    Hi @Anonymous 

     

    If you looking for 2 years from current year then you could use expression 

    add(int(formatDateTime(utcNow(), 'yyyy')),2)

     

    image.png

  • Community Power Platform Member Profile Picture
    on at
    Re: Calculate a date in two years

    Not 2 years from now - The idea is two years from the date in the custom column.
    But Always 30.06.

     

    Example:

    22.01.2019  >> 30.06.2021

    The todays date doesn matter

     

  • abm abm Profile Picture
    32,585 Most Valuable Professional on at
    Re: Calculate a date in two years

    Hi @Anonymous 

     

    So in that case you need to use the flow action get list item. Then get the date and use similar expression I shown you earlier.

  • RobElliott Profile Picture
    10,276 Super User 2025 Season 2 on at
    Re: Calculate a date in two years

    @Anonymous just to show you what @abm's post looks like in your compose action, the syntax would be add(int(formatDateTime(body('Get_item')?['DueDate'],'yyyy')),2)

    where DueDate is the name of my column:
    update2Years.png

    Rob
    Los Gallardos

  • Community Power Platform Member Profile Picture
    on at
    Re: Calculate a date in two years

    Hi Rob,

     

    could you send me the the link to the complete blog article, because with the button it better the with the trigger marked document.

    But the Expression doesnt work for me, my column (defined by the customer) has some blanks and perhaps some other Problems with the Formular.
    If i follow your example i get the message:

    "Correct to include a valid reference to "get_tem) …… because i work with "for a selected file"

  • RobElliott Profile Picture
    10,276 Super User 2025 Season 2 on at
    Re: Calculate a date in two years

    @Anonymous if you're asking how to do the button in your SharePoint list to trigger the flow then have a look at my post earlier today which shows how. https://powerusers.microsoft.com/t5/Connecting-To-Data/Flow-based-on-Button-in-Sharepoint-List/m-p/465559/highlight/true#M7688

    The format of the JSON code you'll need is shown below and you'll need to add the ID of your flow into it to replace mine shown in bold:

     

    {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "button",
    "txtContent": "Escalate",
    "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"661692e4-c2b9-4df2-b6fa-4ab859ca868b\"}"
    }
    }

    Rob
    Los Gallardos

  • Verified answer
    v-bacao-msft Profile Picture
    on at
    Re: Calculate a date in two years

     

    Hi @Anonymous ,

     

    Please consider the following methods to achieve your needs:

    140.PNG141.PNG

    Expression reference:

    add(int(split(outputs('Compose'),'-')[0]),2)

    Hope this helps.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    on at
    Re: Calculate a date in two years

    Hi, i'm after something similar and having issues. Here is some context on my flow.

     

    I am creating an asset management system in Sharepoint and one of the fields is 'Original Install Date'. I want to get an email when the 'Original Install Date' was 2 years ago so I know to prepare a new laptop for the owner. Below is what I have so far. All I need is in the apply to each condition to be: if 'Original Install Date' is greater than 'Original Install Date' +2 years then trigger email.

     

    Any help is appreciated.

     

    JackJarvis10_0-1593599289891.png

    JackJarvis10_1-1593599320744.png

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 788 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 452 Moderator

#3
developerAJ Profile Picture

developerAJ 302

Last 30 days Overall leaderboard