ASP format the function to display time by specified parameters

Source: Internet
Author: User

Date function

Description: Returns the current system date.

Syntax: Date

DATEADD function

Description: Returns the date when the specified time interval has been added.

Syntax: DateAdd (interval, number, date)

Interval: Must choose. A string expression that represents the time interval to add. For numeric values, see the "Settings" section.

Number: Must be selected. Numeric expression that represents the number of time intervals to add. Numeric expressions can be positive (get future dates) or negative numbers (get past dates).

Date: Must be selected. Variant or text to be added to the interval representation date.

The interval parameter can have the following values:

YYYY (year), Q (Quarter), M (month), Y (Day of year), D (Day), W (Day of Week), WW (week), H (hour), N (minutes), S (sec)

Description: Use the DATEADD function to add or subtract a specified time interval from a date. For example, you can use DATEADD to calculate the date 30 days from today or 45 minutes from now. To add a time interval of "Day" to date, you can use the number of days per year (y), day (d), or number of days of the Week (W).

The DATEADD function does not return an invalid date. The following example adds one months to January 31, 95:

Newdate = DateAdd ("M", 1, "31-jan-95")

In this case, DATEADD returns February 28, 95, not February 31, 95. If date is January 31, 96, it returns February 29, 96, because 1996 is a leap year.

An error occurs if the calculated date is before 100 A.D.

If number is not a Long value, it is rounded to the nearest integer before being evaluated.

DateDiff function

Description: Returns the time interval between two dates.

Syntax: DateDiff (interval, date1, date2 [, firstdayofweek[, firstweekofyear>)

Interval: Must choose. A string expression that is used to calculate the time interval between Date1 and Date2. For numeric values, see the "Settings" section.

Date1, Date2: Must choose. An expression of a date. Two dates used for the calculation.

FirstDayOfWeek: 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.

The interval parameter can have the following values:

YYYY (year), Q (Quarter), M (month), Y (Day of year), D (Day), W (Day of Week), WW (week), H (hour), N (minutes), S (sec)

The FirstDayOfWeek parameter can have the following values:

(The following are: 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:

(The following are: 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 of the new Year.

Description: The DateDiff function is used to determine the number of specified time intervals that exist between two dates. For example, you can use DateDiff to calculate the number of days between two date differences, or the day to the last day of the year.

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.