jennifere
asked on
Date Function
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
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
Use the DateDiff Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That will work- Thanks.