The syntax of an ASP DatePart function (used to calculate a date and return a specified time interval) _asp base

Source: Internet
Author: User
Tags constant numeric time interval
DatePart's syntax is DatePart (interval, date), which takes a part of the date.

Interval

The year in the Yyyy:date
The month in the M:date
The day in the D:date
The time in the H:date
The points in the N:date
Seconds in the S:date
Q:date is in the first quarter of the year, for example, in the 2nd quarter of 2009-6-29.
Y:date is located in the first days of the year, such as 2009-6-29 on the 180th day.
W:date is located on the day of the week (default Sunday is the first day), for example, 2009-6-29 is on the 2nd days.
Ww:date is located in the first weeks of the year, for example, in the 27th week of 2009-6-29.

DatePart (interval, date[, firstdayofweek[, FirstWeekOfYear])
The syntax for the DatePart function has the following parameters:

Parameter description
Interval must be selected. A string expression that represents the time interval to return. For numeric values, see the "Settings" section.
Date must be selected. The date expression to evaluate.
Firstdayof Week optional. Specifies the constant for the first day of the week. If not specified, the default is Sunday. For numeric values, see the "Settings" section.
FirstWeekOfYear Optional. Specifies a constant for the first week of the year. If not specified, the default is the week of January 1. For numeric values, see the "Settings" section.


Setting the interval parameter can have the following values:
Set description
YYYY years
Q Quarter
M month
Y number of days in a year
D-Day
W Number of days in a week
WW Week
H hours
M minutes
s seconds


The FirstDayOfWeek parameter can have the following values:

Constant numerical description
Vbusesystem 0 uses the regional language Support (NLS) API settings.
Vbsunday 1 week day (default)
Vbmonday 2 weeks A
Vbtuesday 3 week Two
Vbwednesday 4 week Three
Vbthursday 5 week Four
Vbfriday 6 Friday
Vbsaturday 7 Saturday

The FirstWeekOfYear parameter can have the following values:

Constant numerical description
Vbusesystem 0 uses the regional language Support (NLS) API settings.
VbFirstJan1 1 begins on the week of January 1 (default).
vbFirstFourDays 2 begins with the first week of at least four days in the new year.
Vbfirstfullweek 3 begins with the first full week (not straddling) in the new Year.

Description
The DatePart function is used to calculate the date and return the specified time interval. For example, use DatePart to calculate the day of the week or the current time.
The FirstDayOfWeek parameter affects the calculation using the "W" and "ww" interval symbols.

If date is a date literal, the specified year becomes a fixed part of the date. However, if date is enclosed in quotation marks ("") and the year is omitted, the current year is inserted each time the date expression is evaluated in the code. This allows you to write program code that works for different years.
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.