cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Beat
Helper V
Helper V

Expression to get the date of Friday of the previous week

This expression works

addDays(utcNow(), dayOfWeek(utcNow()), 'dd-MMM-yyyy')
and adds, 1, 2, 3 etc. days in function of the current weekday.
How can I turn dayOfWeek(utcNow() into  - dayOfWeek(utcNow) -2
so that e.g. on a Monday it substracts 3 and on Tuesday it substracts 4 days to give me last Friday's date?
I expected something like 
addDays(utcNow(),-dayOfWeek(utcNow())-2, 'dd-MMM-yyyy')
would work but apparently I'm missing a point or two. 
Some help is greatly appreciated.
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Community Champion
Community Champion

@Beat 

 

You want to use the sub expression.

 

addDays(utcNow(), sub(-2,dayOfWeek(utcNow())), 'dd-MMM-yyyy')
 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

View solution in original post

2 REPLIES 2
DamoBird365
Community Champion
Community Champion

@Beat 

 

You want to use the sub expression.

 

addDays(utcNow(), sub(-2,dayOfWeek(utcNow())), 'dd-MMM-yyyy')
 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

View solution in original post

Indeed, sub() was what I was looking for. Thank you so much for the prompt response! 

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (2,025)