ASP returns the total number of days of code in a year.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.