Skip to main content

Notifications

Power Automate - Building Flows
Answered

Subtracting between dates using sub and subtractFromTime

Posted on by 246

Hello forum.  The forum has been a lifesaver.  So thank you.

 

I am created a flow that checks a SP list for any item that is 30 days from the Expire date (date column in SP).  At 30 days, the flow sends out a notification.  Within the  notification,  I want to have the flow calculate the number of days that the item has been active.  This would be accomplished by taking the current date and subtracting the Created date.  I have tried different expression formulas without success.  

 

-- sub(formatDateTime(utcNow(), 'yyyy-MM-dd'),formatDateTime(items('Apply_to_each_2')?['Created'], 'yyyy-MM-dd')) <-- states that the 1st parameter is a string even after formatting

 

-- subtractFromTime(formatDateTime(utcNow(), 'yyyy-MM-dd'),formatDateTime(items('Apply_to_Each_2')?['Created'],'yyyy-MM-dd'),'Day')

 

-- subtractFromTime(utcNow(),items('Apply_to_Each_2')?['Created'],'Day')

 

Tried variations of the above formulas and have not been successful.  I also tried creating variables and using the Compose action without success.

 

Any ideas?

 

Thanks again for this forum!!  and hope everyone has a safe and wonderful holiday season.

 

 

 

  • Misa Profile Picture
    Misa 246 on at
    Re: Subtracting between dates using sub and subtractFromTime

    @abm 

     

    Thank you so much!  It worked perfectly!!!  I started doing the happy dance.  😄 

  • Verified answer
    abm abm Profile Picture
    abm abm 32,250 on at
    Re: Subtracting between dates using sub and subtractFromTime

    Hi Misa,

     

    Yes this community is fantastic. Thanks for the kind words.

     

    To find the days between two dates please use the below expression

     

    div(sub(ticks(formatDateTime(utcNow(),'yyyy-MM-dd')),ticks(items('Apply_to_each_2')?['Created'])),864000000000)
     
    If you need any further help please let me know.
     
    Thanks
     
     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,532

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,050

Leaderboard