Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Formula for Timeline Dates

Status
Not open for further replies.

beadedbytes

Technical User
Apr 25, 2003
152
US
I need to create a timeline with dates. How would I write a formula that would return workday, but not Sat or Sun or holiday?

Start date 4/9/2009
Start minus 45 2/23/2009 ok
Start minus 70 1/29/2009 ok
Start minus 82 1/17/2009 Sat
Start minus 105 12/25/2008 Holiday
 
Hi,

Which holidays? You must enumerate.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
For this exercise, let's use some of the traditional holidays -- Xmas Eve, Xmas, New Year's. Depending on future needs, other holidays may be added.
 
You will have to enumerate these DATES in a list. My list is named Holidays
[tt]
=IF(MOD(IF(ISNA(MATCH(A11,Holidays,0)),0,1)+A11,7)<2,2-MOD(IF(ISNA(MATCH(A11,Holidays,0)),0,1)+A11,7),0)+IF(ISNA(MATCH(A11,Holidays,0)),0,1)+A11
[tt]
where A11 is the date you want to calculate to the next non-holiday weekday.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I'm realizing that a list of valid dates is the only way to go.

I have worked at several large corporations, and in each case, workdates were not calculated. They are looked up in a table.

The rub comes when holidays are consecutive. I suppose that you could add a column to the lookup table for days to add.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
revised
[tt]
=IF(MOD(IF(ISNA(MATCH(A11,Holidays,0)),0,INDEX(DaysH,MATCH(A11,Holidays,0),1))+A11,7)<2,2-MOD(IF(ISNA(MATCH(A11,Holidays,0)),0,INDEX(DaysH,MATCH(A11,Holidays,0),1))+A11,7),0)+IF(ISNA(MATCH(A11,Holidays,0)),0,INDEX(DaysH,MATCH(A11,Holidays,0),1))+A11
[/tt]
where the table is like...
[tt]
Holidays DaysH
12/25/2008 1
01/01/2009 1
12/24/2009 2
12/25/2009 1
01/01/2010 1
12/24/2010 2
12/25/2010 1
[tt]


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks, Skip. But, I must admit the formula feels a bit daunting.

I remember long ago using the Excel's WORKDAY function, but have not been able to get it to work.
 
Did you read the HELP on WORKDAY?

My formula is based on ...

1. the fact that Sat & Sun dates, the MOD/7 is 0 & 1 respectively. So
[tt]
IF(MOD(YourDate,7)<2,2-MOD(YourDate,7),0)
[/tt]
add 2 to saturdays and 1 to sundays

2. the holidays are lookups, and the return the DaysH to add to a date.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
BTW, I did not write this hairy formula from scratch, left to right.

I build it, from the inside out, in pieces, like the MOD formula I previously posted.

Start with a concept, test, modify, build.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I'm having troubles getting the holidays to skip. Skip - mind taking a look at my spreadsheet?
 


jgochanour,

Please start a new thread, and explain your problem clearly, concisely and completely.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top