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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding the Next available Monday if the Focus date is Saturday 1

Status
Not open for further replies.

rockinhorse

Programmer
Oct 21, 2005
14
US
I need a little help with DateDiff. I am trying to find the next business day for shipping an order. The Order is placed on a Thursday and takes two days to pack before it can ship, but cannot go out on a Saturday or Sunday.
 
in a sql query or in an ASP script...can you show us some relevant code...

-DNG
 
I have sOrderDate, sPromiseDate and sShipDate variables.
An order is placed on Thursday, and we promise to ship the product within two to three days from order, unless the promise date falls on Saturday or Sunday, then ship the following Monday.

sPromiseDate = DateAdd("d",3,sOrderDate)

If Format(sPromiseDate,"dd") = "Saturday" Then
sShipDate = DateAdd("d",5,sOrderDate)
End If

If Format(sPromiseDate,"dd") = "Sunday" Then
sShipDate = DateAdd("d",4,sOrderDate)
End If

Is there something more graceful?
 
You could use a Select case statement on the Weekday function:

Select Case Weekday(sOrderDate)
Case 3
myAdd = 5
Case 4
myAdd = 4
Case Else
myAdd = 3
End Select
sShipDate = sOrderDate + myAdd

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top