cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
Microsoft
Microsoft

@Anonymous 

 

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
Microsoft
Microsoft

@Anonymous 

 

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 😉

Anonymous
Not applicable

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

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (1,418)