Need help with this expression

ShadowsSA

New member
Local time
Today, 04:16
Joined
Jun 15, 2007
Messages
8
I need help setting up an expression. I need to set the default value = date + 2. But this also needs to take into account working days. I am just having problems with the syntax for this, as i would normally do this in VBA and do not have much experience with Expression Builder. And yes it does have to be done in Expression Builder.

I know this is horribly wrong... thats why I am asking for help.
IIf ((WeekDay(DateAdd ("d", 2, Date)) = 1, (DateAdd("d", 3, Date)),(DateAdd("d", 2, Date))) OR IIf (WeekDay(DateAdd ("d", 2, Date)) = 7, (DateAdd("d", 4, Date)),(DateAdd("d", 2, Date))) OR IIf (WeekDay(DateAdd ("d", 2, Date)) < 7 AND IIf (WeekDay(DateAdd ("d", 2, Date)) > 1, (DateAdd ("d", 2, Date),(DateAdd("d", 2, Date)))

I need 3 If statements:
1 for if its Saterday
1 for if its Sunday
1 for if its neither.

In VBA I would do something like this:
If WeekDay(DateAdd ("d", 2. Date)) = 1 Then Box = Date() + 3
If WeekDay(DateAdd ("d", 2. Date)) = 2 Then Box = Date() + 4
If WeekDay(DateAdd ("d", 2. Date)) > 1 And WeekDay(DateAdd ("d", 2. Date)) < 7 Then Box = Date() + 2

Please any assistance would be appreciated
 
Seems like you are over-complicating it.

Take your Starting date and (say) off some event; perhaps a command button, try this:

DayDate = Format(DateStart.Value, "ddd")

Select Case DayDate

Case "Sat"
DateStart = DateStart + 2

Case "Sun"
DateStart = DateStart + 1

Case Else
' Do nothing

End Select
 
Seems like you are over-complicating it.

Take your Starting date and (say) off some event; perhaps a command button, try this:

DayDate = Format(DateStart.Value, "ddd")

Select Case DayDate

Case "Sat"
DateStart = DateStart + 2

Case "Sun"
DateStart = DateStart + 1

Case Else
' Do nothing

End Select

Ted -

I think you didn't catch the part where they said that they needed to use an expression instead of code. My question is, "Are you unable to add a function and then call it in the expression?"
 
Code:
IIf (
 WeekDay(DateAdd("d", 2, Date)) = 1, 
 DateAdd("d", 3, Date),
 IIf (
  WeekDay(DateAdd("d", 2, Date)) = 7, 
  DateAdd("d", 4, Date),
  DateAdd("d", 2, Date)
)
 

Users who are viewing this thread

Back
Top Bottom