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
The actual date <% =Date %>
5/22/2005
<% =Year(date) %>
2005
Add a time period to actual date <% =Mydate %> <% =Year(mydate) %>
Add 3 years to actual date: 
<% Mydate=dateAdd ("yyyy",3,Date) %>
5/22/2008 2008
Add 3 quarters to actual date: 
<% Mydate=dateAdd ("q",3,Date) %>
2/22/2006 2006
Add 3 months to actual date: 
<% Mydate=dateAdd ("m",3,Date) %>
8/22/2005 2005
Add 3 days to actual date:
<% Mydate=dateAdd ("D",3,Date) %>
5/25/2005 2005
Add 24 hours to actual date:
<% Mydate=dateAdd ("h",24,Date) %>
5/22/2005 3:00:00 AM 2005
Add 1440 minutes to actual date: 
<% Mydate=dateAdd ("n",1440,Date) %>
5/22/2005 12:03:00 AM 2005
Add 86400 seconds to actual date: 
<% Mydate=dateAdd ("s",86400,Date) %>
5/22/2005 12:00:03 AM 2005
Month MonthName Day Weekday
<% =Month(date) %>
5
<% =MonthName(month(date)) %>
May
<% =Day(date) %>
22
<% =Weekday(date) %>
1
<% =Month(Mydate) %> <% =MonthName(month(Mydate)) %> <% =Day(Mydate) %> <% =Weekday(Mydate) %>
5 May 22 5
2 February 22 4
8 August 22 2
5 May 25 4
5 May 22 1
5 May 22 1
5 May 22 1

 

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"

 

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









   



MSN Nick Name



More Resources...





Most Viewed Services:
  1. HTML Tutorial
  2. XHTML Tutorial
  3. CSS Tutorial
  4. Javascript Tutorial
  5. DHTML Tutorial
  6. VB Script
  7. TCP/IP Tutorial
  8. ADO Tutorial
  9. MYSQL Tutorial
  10. ASP Tutorial
  11. AJAX Tutorial
  12. CFML Tutorial
  13. PHP Tutorial
  14. WML Tutorial
  15. FLASH Tutorial
  16. XML Tutorial
  17. RSS Tutorial
  18. SQL Tutorial
  19. HTML Articles
  1. Javascript Articles
  2. PHP Articles
  3. SEO Articles
  4. Web Design Articles
  5. SEO Tips
  6. Web Design Tips
  7. Articles
  8. CSS
  9. CSS Tips
  10. HTML Tips
  11. JAVASCRIPT Tips
  12. MYSQL Tips
  13. PHP Tips
  14. Money
  15. Tutorials
  16. Web Hosting



  • Home
  • Web Directory
  • Top Directoriers
  • Webmaster Directories
  • Contact
  • © Copyright 2006-2010 All Rights Reserved By CodeDcode.Com : HTML : RSS : TEXT : XML