Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dates 5 and 7 days from now

Posted on 2014-03-19
7
Medium Priority
?
390 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 33

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 33

Accepted Solution

by:
Big Monty earned 1800 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 33

Assisted Solution

by:Big Monty
Big Monty earned 1800 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 33

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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…

715 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