adsense


Sunday, 8 November 2015

VB SCRIPT DATEADD FUNCTION PAGE 66

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button




VB SCRIPT DATEADD FUNCTION





DateAdd Function 

A Function, which returns a date to which a specified time interval has been added. 
Syntax 
DateAdd(interval,number,date)  
Parameter Description 

• Interval, a Required Parameter. It can take the following values: 

 

o d - day of the year. 

 

o m - month of the year 

 

o y - year of the year 

 

o yyyy - year 

 

o w - weekday 

 


o ww - week 

 

o q - quarter 

 

o h - hour 

 

o m - minute 

 

o s - second 

 

• Number, a Required parameter. It can take both positive and negative parameters. 

 

• Date, a Required parameter. A Variant or literal representing the date to which interval is added. 

Example 
<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
 
' Positive Interal 
date1=01-Jan-2013 
document.write("Line 1 : " &DateAdd("yyyy",1,date1) & "<br />") 
document.write("Line 2 : " &DateAdd("q",1,date1) & "<br />") 
document.write("Line 3 : " &DateAdd("m",1,date1) & "<br />") 
document.write("Line 4 : " &DateAdd("y",1,date1) & "<br />") 
document.write("Line 5 : " &DateAdd("d",1,date1) & "<br />") 
document.write("Line 6 : " &DateAdd("w",1,date1) & "<br />") 
document.write("Line 7 : " &DateAdd("ww",1,date1) & "<br />") 
document.write("Line 8 : " &DateAdd("h",1,"01-Jan-2013 12:00:00") & "<br />") 
document.write("Line 9 : " &DateAdd("n",1,"01-Jan-2013 12:00:00") & "<br />") 
document.write("Line 10 : "&DateAdd("s",1,"01-Jan-2013 12:00:00") & "<br />") 
 
' Negative Interval 
document.write("Line 11 : " &DateAdd("yyyy",-1,date1) & "<br />") 
document.write("Line 12 : " &DateAdd("q",-1,date1) & "<br />") 
document.write("Line 13 : " &DateAdd("m",-1,date1) & "<br />") 
document.write("Line 14 : " &DateAdd("y",-1,date1) & "<br />") 
document.write("Line 15 : " &DateAdd("d",-1,date1) & "<br />") 
document.write("Line 16 : " &DateAdd("w",-1,date1) & "<br />") 
document.write("Line 17 : " &DateAdd("ww",-1,date1) & "<br />") 
document.write("Line 18 : " &DateAdd("h",-1,"01-Jan-2013 12:00:00") & "<br />") 
document.write("Line 19 : " &DateAdd("n",-1,"01-Jan-2013 12:00:00") & "<br />") 
document.write("Line 20 : " &DateAdd("s",-1,"01-Jan-2013 12:00:00") & "<br />")  
</script> 
</body> 
</html> 
When you save it as .html and execute it in Internet Explorer, 
then the above script will produce the following result: 
Line 1 : 27/06/1895 
Line 2 : 27/09/1894 
Line 3 : 27/07/1894 
Line 4 : 28/06/1894 
Line 5 : 28/06/1894 
Line 6 : 28/06/1894 
Line 7 : 4/07/1894 
Line 8 : 1/01/2013 1:00:00 PM 
Line 9 : 1/01/2013 12:01:00 PM 
Line 10 : 1/01/2013 12:00:01 PM 
Line 11 : 27/06/1893 
Line 12 : 27/03/1894 
Line 13 : 27/05/1894 
Line 14 : 26/06/1894 
Line 15 : 26/06/1894 
Line 16 : 26/06/1894 
Line 17 : 20/06/1894 
Line 18 : 1/01/2013 11:00:00 AM 
Line 19 : 1/01/2013 11:59:00 AM 
Line 20 : 1/01/2013 11:59:59 AM 


No comments: