Date input to exclude weekends
Hi Jacob,
basically it is just simply Today (T) + # (0,1,2,3)
i wanted to add a holiday input so that incase eg. Friday is a holiday, i
can make the date skip to Monday, or to the next working day.
Thanks for your help.
Rgds
Ray
"Jacob Skaria" wrote:
OK. Can you explain "Holiday_Adjustment".
Whatif Friday and T+2
Whatif Thursday and T+3
Whatif Sunday and T+1
If this post helps click Yes
---------------
Jacob Skaria
"swiftcode" wrote:
Hi Jacob,
Thanks, it seems to work on the normal date, but the holiday adjsutment if
it falls on a weekend will still reflect the weekend date.
Wuld it be possible for example, if i have a holiday adjustment for "T" and
my current date falls on a saturday to take automatically monday, or if "T +
1" also monday, but "T + 2" and "T + 3" to give tuesday and wednesday
respectively?
Many thanks for your help on this.
Rgds
Ray
"Jacob Skaria" wrote:
Try the below
Function SetDate(Current_Date, Holiday_Adjustment)
SetDate = Current_Date + Val(Replace(Holiday_Adjustment, "T", ""))
If Weekday(SetDate) = 1 Then SetDate = SetDate + 1
If Weekday(SetDate) = 7 Then SetDate = SetDate + 2
End Function
If this post helps click Yes
---------------
Jacob Skaria
"swiftcode" wrote:
Hi all,
I seem to have a problem with making my dates auto adjust itself. Here's
what the problem is. I would like to have a date whereby if it is falls on a
weekend to auto adjust itself to monday, but if i have a holiday adjustment,
then to take into account the number of holidays and adjust accordingly. This
is what i've doe so fat bu it doesn't seem to work.
Function SetDate(Current_Date, Holiday_Adjustment)
If Holiday_Adjustment = "T" Then
Date_Adj = 0
ElseIf Holiday_Adjustment = "T + 1" Then
Date_Adj = 1
ElseIf Holiday_Adjustment = "T + 2" Then
Date_Adj = 2
ElseIf Holiday_Adjustment = "T + 3" Then
Date_Adj = 3
End If
WeekDayNum = Weekday(Current_Date)
If WeekDayNum = 2 Then
Date_Adj1 = 0
ElseIf WeekDayNum = 3 Then
Date_Adj1 = 0
ElseIf WeekDayNum = 4 Then
Date_Adj1 = 0
ElseIf WeekDayNum = 5 Then
Date_Adj1 = 0
ElseIf WeekDayNum = 6 Then
Date_Adj1 = 0
ElseIf WeekDayNum = 7 Then
Date_Adj1 = 2
ElseIf WeekDayNum = 1 Then
Date_Adj1 = 1
End If
SetDate = Current_Date + Date_Adj + Date_Adj1
End Function
I would appreciate any help that anyone can give. Thank you in advance.
Rgds
Ray
|