Date Due Based an another Field

J

jlo

I have a field in a form called strPriority. If the priority is High it will
return the current date in the dtmDueDate field. If the priority is Medium
it will return the next day of the current date in dtmDueDate field. If the
priority is Low it will return 2 days of the current date in dtmDueDate
field.

Is it possible to exclude weekends and holidays?

Any help is appreciated.

Thanks.
 
A

Al Campagna

jlo,
Assuming that you might be calculating this dtmDueDate on any day
(including Saturday or a Sunday)

For Medium...
If WeekDay(Date() + 1) = 7 Then 'if Today +1 = Sat
dtmDueDate = Date() + 2
ElseIf WeekDay(Date() + 1) = 1 Then 'if Today +1 =Sun
dtmDueDate = Date() + 1
Else
dtmDueDate = Date() + 1
End if

Use the same logic for your High (+0), or Low (+2)

If you would never be running this calculation on a Saturday or Sunday,
you can skip some of the logic, but the above should work for any entry
date.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
K

KARL DEWEY

You can use nested IIFs to add days that are not the weekend.
Like this UNTESTED --
Expr1:
IIf(Weekday(Date()+1)=7,IIf(Weekday(Date()+2)=1,Weekday(Date()+3),Weekday(Date()+1)))
 
J

jlo

Thank you. I will give this a try!

Al Campagna said:
jlo,
Assuming that you might be calculating this dtmDueDate on any day
(including Saturday or a Sunday)

For Medium...
If WeekDay(Date() + 1) = 7 Then 'if Today +1 = Sat
dtmDueDate = Date() + 2
ElseIf WeekDay(Date() + 1) = 1 Then 'if Today +1 =Sun
dtmDueDate = Date() + 1
Else
dtmDueDate = Date() + 1
End if

Use the same logic for your High (+0), or Low (+2)

If you would never be running this calculation on a Saturday or Sunday,
you can skip some of the logic, but the above should work for any entry
date.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top