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 if date is c...
Power Automate
Unanswered

Calculate if date is current or prior week

(0) ShareShare
ReportReport
Posted on by 64

Hi,

I'm trying to compare a Date if is this current or last week but I keep getting error. Can you help?

 

 

if(
 and(
 lessOrEquals(addDays(utcNow(), mul(dayOfWeek(utcNow()), 0), 'MM-dd-yyyy'), 
 formatDateTime(utcNow(), 'MM-dd-yyyy')),
 greaterOrEquals(addDays(utcNow(), add(6, mul(dayOfWeek(utcNow()), 0)), 'MM-dd-yyyy'), 
 formatDateTime(utcNow(), 'MM-dd-yyyy'))

,'Current','Past'))

 

 

I'm getting this error

 

Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language function 'if' expects three parameter: the condition to test as the first parameter, the value to return if the condition is true as the second parameter, and the value to return if the condition is false as the third parameter. The function was invoked with '1' parameter(s). Please see https://aka.ms/logicexpressions#if for usage details.'.

 

 

Categories:
  • ScottShearer Profile Picture
    25,331 Most Valuable Professional on at

    @Spaceballs 

    You can't use operators like <= or >= in Flow expressions.  You need to use comparison expressions such as less() and lessOrEquals(), etc..  Your expression will end up being way complicated - I suggest doing it in a number of steps using Compose actions.

     

    image.png

    I approached this a little differently using a series of Compose actions and converting the dates to ticks,

    image.pngimage.png

     

  • Spaceballs Profile Picture
    64 on at

    In the Sharepoint list I have three calculated fields

     

    StartWeek

    =ApproveDate-(WEEKDAY(ApproveDate,3))

     

    EndWeek

    =ApproveDate+(6-WEEKDAY(ApproveDate,3))

     

    WeekdayFlag

    =IF(AND(WeekStart<=TODAY(),WeekEnd>=TODAY()),"This week","Past Week")

     

    How can I translate back to the Power Automate in one expression rather than split it into multiple variables. One compose to rule them all 🙂

  • ScottShearer Profile Picture
    25,331 Most Valuable Professional on at

    @Spaceballs 

    Try replacing the operators like + - >=, etc. with expressions as i mentioned in my earlier post.  Give it a try and post any questions that you have here but give it a try......

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 414

#2
11manish Profile Picture

11manish 331 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard