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
Super User
Super User

@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
Super User
Super User

@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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,424)