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
Solved

Dates 5 and 7 days from now

Posted on 2014-03-19
7
375 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 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 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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 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 33

Expert Comment

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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 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