[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Date Function

Posted on 2003-12-01
3
Medium Priority
?
716 Views
Last Modified: 2010-05-03
I am trying to use the Date function to return a date range from the current date to 5 days back.  The trick is it needs to be formatted like this:
2003-11-15-2003-11-30

Below is my orginal code.  However, as I discovered this morning, it doesn't take into consideration month changes or leap years.  Is there an easy way to do this??
   
daysBack = Year(Date) & "-" & Month(Date) & "-" & Day(Date) - 5
currentDate = Year(Date) & "-" & Month(Date) & "-" & Day(Date)  
rangeDate = daysBack & "-" & currentDate
0
Comment
Question by:jennifere
[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
  • 2
3 Comments
 
LVL 9

Expert Comment

by:dancebert
ID: 9852178
Use the DateDiff Function

0
 
LVL 9

Accepted Solution

by:
dancebert earned 500 total points
ID: 9852202
Oops, I meant the DateAdd fuction

Dim currentDate As Date
currentDate = Now
Dim daysBack As Date
daysBack = DateAdd("d", -5, currentDate)
rangeDate = cstr(daysBack) & "-" & currentDate
0
 

Author Comment

by:jennifere
ID: 9852265
That will work-  Thanks.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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