List of free web storage providers. Save up to 50 GB online.

Add time period to date
In the table  the actual servers date is shown(first part of the table), and bellow we have add diferent intervals of times to actual date. The new date has been saved to a variable named Mydate and  date, year, month, monthname, day, and weekday corresponding to Mydate has been shown in each line .

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 %>
7/9/2008
<% =Year(date) %>
2008
<% =Month(date) %>
7
<% =MonthName(month(date)) %>
July
<% =Day(date) %>
9
<% =Weekday(date) %>
4
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) %>
7/9/2011 2011 7 July 9 7
Add 3 quarters to actual date: 
<% Mydate=dateAdd ("q",3,Date) %>
4/9/2009 2009 4 April 9 5
Add 3 months to actual date: 
<% Mydate=dateAdd ("m",3,Date) %>
10/9/2008 2008 10 October 9 5
Add 3 days to actual date:
<% Mydate=dateAdd ("D",3,Date) %>
7/12/2008 2008 7 July 12 7
Add 24 hours to actual date:
<% Mydate=dateAdd ("h",24,Date) %>
7/9/2008 3:00:00 AM 2008 7 July 9 4
Add 1440 minutes to actual date: 
<% Mydate=dateAdd ("n",1440,Date) %>
7/9/2008 12:03:00 AM 2008 7 July 9 4
Add 86400 seconds to actual date: 
<% Mydate=dateAdd ("s",86400,Date) %>
7/9/2008 12:00:03 AM 2008 7 July 9 4

 

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 Wednesday.
 

Create word search puzzles with your own words



Add Country identification to your site

Tutorial home page

2008@ AspTutorial.info. All rights reserved.