adsense


Sunday, 8 November 2015

VB SCRIPT DATEDIFF FUNCTION PAGE 67

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




VB SCRIPT DATEDIFF FUNCTION




DateDiff Function 

It is a function that returns the difference between two specified time intervals. 
Syntax 
DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]])  
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 

 

• date1 and date2 are Required parameters. 

 

• firstdayofweek is Optional. Specifies the first day of the week.
 It can take the following values: 

 

o 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting 

 

o 1 = vbSunday - Sunday 

 

o 2 = vbMonday - Monday 

 

o 3 = vbTuesday - Tuesday 

 

o 4 = vbWednesday - Wednesday 

 

o 5 = vbThursday - Thursday 

 

o 6 = vbFriday - Friday 

 


o 7 = vbSaturday - Saturday 

 

• firstdayofyear is Optional. Specifies the first day of the year. It can take the following values: 

 

o 0 = vbUseSystem - Use National Language Support (NLS) API setting 

 

o 1 = vbFirstJan1 - Start with the week in which January 1 occurs (default) 

 

o 2 = vbFirstFourDays - Start with the week that has at least four days in the new year 

 

o 3 = vbFirstFullWeek - Start with the first full week of the new year 

Example 
<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
 
fromDate="01-Jan-09 00:00:00" 
toDate="01-Jan-10 23:59:00" 
document.write("Line 1 : " &DateDiff("yyyy",fromDate,toDate) & "<br />") 
document.write("Line 2 : " &DateDiff("q",fromDate,toDate) & "<br />") 
document.write("Line 3 : " &DateDiff("m",fromDate,toDate) & "<br />") 
document.write("Line 4 : " &DateDiff("y",fromDate,toDate) & "<br />") 
document.write("Line 5 : " &DateDiff("d",fromDate,toDate) & "<br />") 
document.write("Line 6 : " &DateDiff("w",fromDate,toDate) & "<br />") 
document.write("Line 7 : " &DateDiff("ww",fromDate,toDate)& "<br />") 
document.write("Line 8 : " &DateDiff("h",fromDate,toDate) & "<br />") 
document.write("Line 9 : " &DateDiff("n",fromDate,toDate) & "<br />") 
document.write("Line 10 : "&DateDiff("s",fromDate,toDate) & "<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 : 1 
Line 2 : 4 
Line 3 : 12 
Line 4 : 365 
Line 5 : 365 
Line 6 : 52 
Line 7 : 52 
Line 8 : 8783 
Line 9 : 527039 
Line 10 : 31622340 



No comments: