The format of the DateAdd function is
DateAdd(code, count, date)
Code comes from the table below and indicates what unit of time you are adding to your initial date:
Code | Time Span |
yyyy | Year |
q | Quarter |
m | Month |
y | Day of year |
d | Day |
w | Weekday |
ww | Week of year |
h | Hour |
n | Minute |
s | Second |
Count is the number of those units you will be adding - 3 days, 4 hours, 1 month. This can be negative if you want to go backwards in time.
Date is the starting date you wish to begin with.
So to take today's date and figure out what the date was one month ago, you would use
DateAdd("m", -1, Now())
Date and Time Functions
Introduction to ASP Ebook Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages. |