| Add time period to date |
This kind of code may be useful to display the correct date corresponding
to a country or region when the server is located in a different country
(for example, the server is located in US, and the visitors are from Spain)
| date | Year | Month | MonthName | Day | Weekday | |
| The actual date | <% =Date %>
9/13/2008 |
<% =Year(date) %>
2008 |
<% =Month(date) %>
9 |
<% =MonthName(month(date)) %>
September |
<% =Day(date) %>
13 |
<% =Weekday(date) %>
7 |
| Add a time period to actual date | <% =Mydate %> | <% =Year(mydate) %> | <% =Month(Mydate) %> | <% =MonthName(month(Mydate)) %> | <% =Day(Mydate) %> | <% =Weekday(Mydate) %> |
| Add 3 years to actual date:
<% Mydate=dateAdd ("yyyy",3,Date) %> |
9/13/2011 | 2011 | 9 | September | 13 | 3 |
| Add 3 quarters to actual date:
<% Mydate=dateAdd ("q",3,Date) %> |
6/13/2009 | 2009 | 6 | June | 13 | 7 |
| Add 3 months to actual date:
<% Mydate=dateAdd ("m",3,Date) %> |
12/13/2008 | 2008 | 12 | December | 13 | 7 |
| Add 3 days to actual date:
<% Mydate=dateAdd ("D",3,Date) %> |
9/16/2008 | 2008 | 9 | September | 16 | 3 |
| Add 24 hours to actual date:
<% Mydate=dateAdd ("h",24,Date) %> |
9/13/2008 3:00:00 AM | 2008 | 9 | September | 13 | 7 |
| Add 1440 minutes to actual date:
<% Mydate=dateAdd ("n",1440,Date) %> |
9/13/2008 12:03:00 AM | 2008 | 9 | September | 13 | 7 |
| Add 86400 seconds to actual date:
<% Mydate=dateAdd ("s",86400,Date) %> |
9/13/2008 12:00:03 AM | 2008 | 9 | September | 13 | 7 |
Date intervals constants used in the table
above and some more.
| Time period | Constant |
| Year | "yyyy" |
| Quarter | "q" |
| Month | "m" |
| Day of year | "y" |
| Day | "D" |
| Weekday | "w" |
| Week of the year | "ww" |
| Hour | "h" |
| Minute | "n" |
| Second | "s" |
Meaning of numbers for Weekday
1 Sunday
2 Monday
3 Tuesday
4 Wednesday
5 Thursday
6 Friday
7 Saturday
The next code will show the name of the weekday
<% =weekdayname(number) %>
p.e: the results for <% =weekdayname(1) %> will be "Sunday"
The next code will show the name of the weekday for date
Today is <% =weekdayname(weekday(date)) %>
Result: Today is Saturday.