Solved

Dates 5 and 7 days from now

Posted on 2014-03-19
7
371 Views
Last Modified: 2014-03-19
I'm trying to get the dates, 5 and 7 days from now.
Example: Today = 3/19/2013, 5 days = 3/24/2013, 7 days = 3/26/2013

I do not want to count weekends, ie only count business days Mon-Fri.
Example: Today = 3/19/2013, 5 days = 3/26/2013, 7 days = 3/28/2013

Working in classic asp
<% 
Dim strToday, strFive, strSeven
strToday = Date()
strFive = Date() + 5
strSeven = Date() + 7
%>

Today: <%=strToday %><br />
5 Days: <%=strFive %><br />
7 Days: <%=strSeven %>

Open in new window

0
Comment
Question by:swaggerking
  • 4
  • 3
7 Comments
 
LVL 32

Expert Comment

by:Big Monty
ID: 39940144
use the DateAdd function:

<% 
Dim strToday, strFive, strSeven
strToday = now
strFive = DateAdd( "d", 5, strToday )
strSeven = DateAdd( "d", 7, strToday )
%>

Today: <%=strToday %><br />
5 Days: <%=strFive %><br />
7 Days: <%=strSeven %>

Open in new window

0
 

Author Comment

by:swaggerking
ID: 39940171
Big Monty,
This still counts weekends. I only want it to count business days.
0
 
LVL 32

Accepted Solution

by:
Big Monty earned 450 total points
ID: 39940325
read too fast, my apologies :)

try this:

<%
dim strToday, businessDays5, businessDays7
strToday = now()

select case WeekDay( strToday )
    case 2, 3, 4     '-- Monday - Wednesday
           businessDays5 = 7
           businessDays7 = 9
    case 5, 6    '-- Thursday - Friday
           businessDays5 = 7
           businessDays7 = 11
end select

strFive = DateAdd( "d", businessDays5, strToday )
strSeven = DateAdd( "d", businessDays7, strToday )
%>

Today: <%=strToday %><br />
5 Days: <%=strFive %><br />
7 Days: <%=strSeven %>

Open in new window


untested, but I think it'll work
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:swaggerking
ID: 39940409
No problem, I do it all the time.  This works, but only if the date (strToday) doesn't land on a weekend.

ie. if strToday = 3/22/2013 (weekend) then strFive and strSeven = 3/22/2013 as well.
0
 
LVL 32

Assisted Solution

by:Big Monty
Big Monty earned 450 total points
ID: 39940425
you'll need to add case conditions for both saturday and sunday, so change my case statement to:

select case WeekDay( strToday )
    case 1     '-- Sunday
           businessDays5 = 5
           businessDays7 = 9
    case 2, 3, 4     '-- Monday - Wednesday
           businessDays5 = 7
           businessDays7 = 9
    case 5, 6    '-- Thursday - Friday
           businessDays5 = 7
           businessDays7 = 11
    case 7     '-- Saturday
           businessDays5 = 6
           businessDays7 = 10
end select

Open in new window

0
 

Author Comment

by:swaggerking
ID: 39940447
Thanks. I appreciate your help.
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 39940458
my pleasure! happy coding :)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now