Share via


get date of last Friday

Question

Wednesday, April 25, 2012 2:55 PM

Hi, for a purpose i need to get previous-day from current-date:

$wdate = (Get-Date).addDays(-1)

BUT, when the current-date is Monday, I must have to receive the date of 'Last Friday' as result, which means last business day of last week.

Any idea please?

All replies (1)

Wednesday, April 25, 2012 3:01 PM âś…Answered | 1 vote

This should do it

if ((get-date).DayOfWeek -eq "Monday" ) { $w = (Get-Date).addDays(-3) } else {$w = (Get-Date).addDays(-1) }

Cyreli