10.7 DateSerial
The DateSerial function returns a Variant of subtype Date for a specified year, month, and day.
Syntax
DateSerial(year,month,day)
Parameter
Description
year
Required. A number between 100 and 9999, or a numeric expression. Values between 0 and 99 are interpreted as the years 1900–1999. For all other year arguments, use a complete four-digit year
month
Required. Any numeric expression
day
Required. Any numeric expression
Example 1
document.write(DateSerial(1996,2,3) & "
")document.write(DateSerial(1990-20,9-2,1-1))Output:2/3/19966/30/1970
10.8 DateValue
The DateValue function returns a Variant of subtype Date.
Note: If the year part of date is omitted this function will use the current year from the computer's system date.
Note: If the date parameter includes time information it will not be returned. However, if date includes invalid time information, a run-time error will occur.
Syntax
DateValue(date)
Parameter
Description
date
Required. A date from January 1, 100 through December 31, 9999 or any expression that can represent a date, a time, or both a date and time
Example 1
document.write(DateValue("31-Jan-02") & "
")document.write(DateValue("31-Jan") & "
")document.write(DateValue("31-Jan-02 2:39:49 AM"))Output:1/31/20021/31/20021/31/2002
10.9 Day
The Day function returns a number between 1 and 31 that represents the day of the month.
Syntax
Day(date)
Parameter
Description
date
Required. Any expression that can represent a date
Example 1
document.write(Date & "
")document.write(Day(Date))Output:1/14/200214
Sunday, January 13, 2008
Vb Script Tutorial
10.6 DatePart
The DatePart function returns the specified part of a given date.
Syntax
DatePart(interval,date[,firstdayofweek[,firstweekofyear]])
Parameter
Description
interval
Required. The interval of time to return.
Can take the following values:
yyyy - Year
q - Quarter
m - Month
y - Day of year
d - Day
w - Weekday
ww - Week of year
h - Hour
n - Minute
s - Second
date
Required. Date expression to evaluate
firstdayofweek
Optional. Specifies the day of the week.
Can take the following values:
0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
1 = vbSunday - Sunday (default)
2 = vbMonday - Monday
3 = vbTuesday - Tuesday
4 = vbWednesday - Wednesday
5 = vbThursday - Thursday
6 = vbFriday - Friday
7 = vbSaturday - Saturday
firstweekofyear
Optional. Specifies the first week of the year.
Can take the following values:
0 = vbUseSystem - Use National Language Support (NLS) API setting
1 = vbFirstJan1 - Start with the week in which January 1 occurs (default)
2 = vbFirstFourDays - Start with the week that has at least four days in the new year
3 = vbFirstFullWeek - Start with the first full week of the new year
Example 1
document.write(Date & "
")document.write(DatePart("d",Date))Output:1/14/200214
The DatePart function returns the specified part of a given date.
Syntax
DatePart(interval,date[,firstdayofweek[,firstweekofyear]])
Parameter
Description
interval
Required. The interval of time to return.
Can take the following values:
yyyy - Year
q - Quarter
m - Month
y - Day of year
d - Day
w - Weekday
ww - Week of year
h - Hour
n - Minute
s - Second
date
Required. Date expression to evaluate
firstdayofweek
Optional. Specifies the day of the week.
Can take the following values:
0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
1 = vbSunday - Sunday (default)
2 = vbMonday - Monday
3 = vbTuesday - Tuesday
4 = vbWednesday - Wednesday
5 = vbThursday - Thursday
6 = vbFriday - Friday
7 = vbSaturday - Saturday
firstweekofyear
Optional. Specifies the first week of the year.
Can take the following values:
0 = vbUseSystem - Use National Language Support (NLS) API setting
1 = vbFirstJan1 - Start with the week in which January 1 occurs (default)
2 = vbFirstFourDays - Start with the week that has at least four days in the new year
3 = vbFirstFullWeek - Start with the first full week of the new year
Example 1
document.write(Date & "
")document.write(DatePart("d",Date))Output:1/14/200214
Subscribe to:
Posts (Atom)