CopyCode The Code is as follows: 'returns the total number of days in a year.
Function dayofyear (byval y)
Dayofyear = datepart ("Y", Y & "-12-31 ")
End function5
'Example: Response. Write dayofyear (2012)
Detailed Syntax of ASP datepart Functions
Datepart (interval, date [, firstdayofweek [, firstweekofyear])
The syntax of the datepart function includes the following parameters:
Parameter description
Interval is required. String expression, indicating the time interval to return. For values, see the "Settings" section.
Date is required. The date expression to be calculated.
Firstdayof week is optional. Specifies the constant of the first day of a week. If not specified, the default value is Sunday. For values, see the "Settings" section.
Firstweekofyear is optional. Specifies the constant of the first week of a year. If this parameter is not specified, the default value is the week of April 1, January 1. For values, see the "Settings" section.
You can set the interval parameter to the following values:
Set description
Yyyy
Q quarter
M month
Y number of days in a year
D
Number of days per week
WW week
H hour
M minutes
S seconds
The firstdayofweek parameter can have the following values:
Constant Value description
Vbusesystem 0 is set using the regional language (NLS) API.
Vbsunday 1 Sunday (default)
Vbmonday 2 Monday
Vbtuesday 3 Tuesday
Vbwednesday 4
Vbthursday 5 Thursday
Vbfriday 6 Friday
Vbsaturday 7 Saturday
The firstweekofyear parameter can have the following values:
Constant Value description
Vbusesystem 0 is set using the regional language (NLS) API.
Vbfirstjan1 starts from the week of July 1, January 1 (default ).
Vbfirstfourdays 2 starts from the first week of at least four days in the New Year.
Vbfirstfullweek 3 starts from the first full week (not cross year) in the new year.
Description
The datepart function is used to calculate the date and return the specified time interval. For example, datepart is used to calculate the day of a week or the current time.
The firstdayofweek parameter affects the calculation of the interval between "W" and "ww.
If date is a date text, the specified year will become a fixed part of the date. However, if date is included in quotation marks ("") and the year is omitted, the current year will be inserted every time the date expression is calculated in the code. In this way, you can writeProgramCode.