Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DateAdd to get previous business day

Posted on 2000-04-20
2
Medium Priority
?
319 Views
Last Modified: 2009-12-16
How would I code a DateAdd function to get the previous business day?  The below gets the previous day, but I want the previous business day, M-F.

DateAdd("d","4/17/2000",-1) = "4/16/2000" (Sunday)
0
Comment
Question by:gabrielf072699
2 Comments
 
LVL 1

Accepted Solution

by:
jbilsten earned 400 total points
ID: 2735595
Well first off, I believe DateAdd is (interval, number, date)

Then your solution is this:

<%

Date = "4/16/2000"

Select Case WeekDay(DateAdd("d",-1,Date))
   Case 1 'Sunday
      Date = DateAdd("d",-3,Date)
   Case 7 'Saturday
      Date = DateAdd("d",-2,Date)
   Case Else
      Date = DateAdd("d",-1,Date)
End Select

%>

Good Luck
0
 

Author Comment

by:gabrielf072699
ID: 2736451
Thanks!!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question