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 Automate / Calculate the differen...
Power Automate
Unanswered

Calculate the difference between 2 dates

(0) ShareShare
ReportReport
Posted on by 2,297

How to calculate the number of days from today to next month's day 5?

 

sub(startOfDay(addDays(startOfMonth(addDays(utcNow(), 30)), 4)), startOfDay(utcNow()))
 
Returns:
Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language function 'sub' expects its first parameter to be an integer or a decimal number. The provided value is of type 'String'. Please see https://aka.ms/logicexpressions#sub for usage details.'.
 
But Power Automate's HORRIBLE function syntax and HORRIBLE editor, this isn't easy...
 
Can anyone pleas help???
Categories:
  • ChristianAbata Profile Picture
    8,953 Most Valuable Professional on at

    Hey @WebPortal  pleas try sub(int(formatDateTime(startOfDay(addDays(startOfMonth(addDays(utcNow(), 30)),4)),'dd')),int(formatDateTime(startOfDay(utcNow()),'dd')))

     

    I've added 2 expressions 

    1.- format day time to convert date to only one day

    2.- int .- to convert the day in integer

     

    I hope this can helps

  • WebPortal Profile Picture
    2,297 on at

    Hi @ChristianAbata 

     

    Thank you so much for helping.

     

    That expression is returning 5-22 = -17

    But from today (22-3-2022) until (5-4-2022) there are only 14 days.

  • WebPortal Profile Picture
    2,297 on at

    I've figured out the solution may be:

     

    div(sub(ticks(formatDateTime(startOfDay(utcNow()))), ticks(formatDateTime(startOfDay(addDays(startOfMonth(getFutureTime(1, 'Month')),4))))),864000000000)
     
    Thank you "low code"!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 423

#2
11manish Profile Picture

11manish 308 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 177

Last 30 days Overall leaderboard