+ Start a Discussion
T-HanT-Han 

Formula - Adding num of days to a Date field and calculating the Date, but it has to be a WEEK DAY.

Hi Y'all - who will be asisting me..!

 

Start Date 1 - Date field, End Date 1 - Formula Field.

Start Date 2 - Date field, End Date 2 - Formula Field.

 

End Date 2 = {Start Date 1 + (3 days) } - but it should not be a Weekend.

 

If its a weekend, then it has to be a next weekday.

Eg: If "End Date 2 calculates to be - Saturday", the formula should calculate and the answer should be Monday's Date.

 

On the whole End Dates should have the dates from M-F.

 

Assistance on this is highly appreciated.? 

 

Thanks..!

 

Best Answer chosen by Admin (Salesforce Developers) 
T-HanT-Han

phiberoptik -

 

Thanks for the link you posted. I got some assistance fr a person there and resolved the issue.

 

Below is the Code which was used fr my Scenario:

 

Scenario: Having a Start Date and need to calculate +4 days / which ever needed , from a Start Date. Excluding the Weekends.

 

Soln:

 

CASE(MOD(DATEVALUE(Start Date) - DATE(1900, 1, 7) , 7),
0, Start Date+4,
1, Start Date+3,
2, Start Date+3,
3, Start Date+5,
4, Start Date+5,
5, Start Date+5,
6, Start Date+4,
null)

 

Worked perfectly.! 

 

Thanks fr you assistance on the POST, else I wouldn't have gone so far.

 

-T

All Answers

phiberoptikphiberoptik
See if some of the formula in this question will give you enough guidance to figure it out for your formula.

http://boards.developerforce.com/t5/Formulas-Validation-Rules/Formula-without-weekends/m-p/555643/highlight/true#M17281
T-HanT-Han

@phiberoptik -

I am tryin to figure out if it would work, I will post the code if all works well. Else would still be needing assistance. ;) 

T-HanT-Han

phiberoptik -

 

Thanks for the link you posted. I got some assistance fr a person there and resolved the issue.

 

Below is the Code which was used fr my Scenario:

 

Scenario: Having a Start Date and need to calculate +4 days / which ever needed , from a Start Date. Excluding the Weekends.

 

Soln:

 

CASE(MOD(DATEVALUE(Start Date) - DATE(1900, 1, 7) , 7),
0, Start Date+4,
1, Start Date+3,
2, Start Date+3,
3, Start Date+5,
4, Start Date+5,
5, Start Date+5,
6, Start Date+4,
null)

 

Worked perfectly.! 

 

Thanks fr you assistance on the POST, else I wouldn't have gone so far.

 

-T

This was selected as the best answer
phiberoptikphiberoptik
Cheers! Glad you figured it out.
T-HanT-Han

Got Kudos? I see something here but not sure what it is..?! Subscribe or something/?

phiberoptikphiberoptik

Ha, thats my profile signature.

 

Kudos is a new feature on the boards where you can give each other kudos, which are basically like saying "thanks you helped me out". You just click the star under the user's name in their posts.