Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Unanswered

Calculating the difference between two dates and updating a sharepoint list item

(0) ShareShare
ReportReport
Posted on by 2

Disregard this post: I found a much easier solution, I just created a calculated column in sharepoint list. and I will just create a simple re-occurrence trigger to update those fields each day.

 

 

 

Hello all,

I am having trouble with a flow and updating a list item in my sharepoint list.

 

Goal:

Everyday at 5 am I need two columns updated in my SharePoint list.

1. TodayDate-I have this working using the utcNow() expression.

2. Eligibility- This is the one I am having issues with. What I am trying to do is compare a Date of Birth column with the TodayDate column, if the value is greater than or equal to 19 years, then I need to mark the column as Ineligible, if the value is <19, then mark as eligible. 

 

I cannot get the first step to work properly, I am having a difficult time trying to calculate the years between the Date of Birth column and the TodayDate column. I tried using =DATEDIF(DOB,TodayDate,"Y") but it says the expression is invalid. If I simply type it in my update item action field, it updates all the items in the list as the actual formula, "=DATEDIF(DOB,TodayDate,"Y")".

 

Can anyone please help me out?

 

  • JGmustang37 Profile Picture
    2 on at
    Re: Calculating the difference between two dates and updating a sharepoint list item

    I referred to the following site for basic syntax:

    https://support.office.com/en-us/article/examples-of-common-formulas-in-sharepoint-lists-d81f5f21-2b4e-45ce-b170-bf7ebf6988b3

     

    and just added what I knew from previous experience.

     

    Final formula for my calculated column:

     

    This checks the Date of birth column and compares it to the current date column:

    =IF(DATEDIF(DOB,TodayDate,"Y")<=18,"eligible",IF(DATEDIF(DOB,TodayDate,"Y")>=19,"Ineligible"))

     

    To automate the daily update of the TodayDate column, I created a recurrence>Get Item> Apply to each flow that updated my TodayDate column with the expression: utc(NOW().

     

    This runs at 5:00 am every day and updates all items in the TodayDate column with the current date.

     

    I then created another Recurrence>Send HTTP Request to SharePoint flow that reposts the calculated column each day at 5:05 and re-runs the calculated formula.

     

    I used this article as a reference:https://us.flow.microsoft.com/manage/environments/Default-b945c813-dce6-41f8-8457-5a12c2fe15bf/flows/9e0c6353-7281-4fe7-9549-0b4ce2872b9b

     

    Due to my company policies, I can not change my system's date and re-run the flow to see if this last flow works, but I will be able  to check first thing in the morning as I have data setup to trigger the ineligibility result tomorrow.

     

     

  • mcin9781 Profile Picture
    on at
    Re: Calculating the difference between two dates and updating a sharepoint list item

    Great, do you have an article that showed you how to do this?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,635 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow