View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David Biddulph[_2_] David Biddulph[_2_] is offline
external usenet poster
 
Posts: 8,651
Default Skip Weekends in date

If you use WEEKDAY(A1-1,2) or WEEKDAY(A1-1,3), the numbers for Saturday and
Sunday will be adjacent, but using WORKDAY is probably the neater solution.
--
David Biddulph

"Stan Brown" wrote in message
t...

WEEKDAY(...) returns 1 to 7 for Sunday through Saturday. So you want
A1-1 usually, but A1-3 if weekday(A1-1) is a 7 or 1:

=IF(OR(WEEKDAY(A1-1)=7,WEEKDAY(A1-1)=1),A1-3,A1-1)

I'm not too fond of computing WEEKDAY twice, but there's a better way
using MOD. MOD(1,7) is 1 and MOD(7,7) is 0, so a faster way to test
for 1 or 7 is

=IF(MOD(WEEKDAY(A1-1),7)<2,A1-3,A1-1)


Tue, 18 Dec 2007 06:48:02 -0800 from Nigel
:
I am trying to skip weekends from a date in a spreadsheet,

In Cell A1 I have todays date

In cell A2 A3 A4 A5 I need it to be the previous days date so based on
todays date
A2 would be 12-17, A3 tho would have to be 12-14,