Solution to date and time in. NET

Source: Internet
Author: User

In ASP. Net programming, in the data used, date and time is a special data type and is often used. Date and Time data in Visual Basic. NET is saved as numerical data and has a range. The date range is from January 1, January 1 ~ January 1, 9999 AD, February 3, the time range is 00:00:00 ~ 23:59:59. The Declaration format is as follows:
Variable = # mm/dd/yyyy #
Variable = # mm-dd-vvvv #
Common functions
Visual Basic. NET defines some common datetime functions for designers. Common functions are as follows:
Now () returns the current period and time
Year (X) returns the middle-aged part of X.
Month (X) returns the part of X in the middle of the Month.
DaY (X,) returns the part of X in China and Japan
Weekday (X) returns X as the day of the week.
Hour (X) returns the portion in X
Minute (X) returns the parts in X
Second (X) returns the Second part of X.
Date Time object
This object provides many attributes and methods for processing date and time. common attributes and methods of the object are as follows:
Now returns the current date and time of the system.
Today returns the current date of the system.
DateTime. Today. Year () returns the current Year of the system.
DateTime. Today. Month () returns the current Month of the system.
DateTime. Today. Day () returns the current Day of the system.
DateTime. Now. DayOfWeek0 returns the current week of the system.
DateTime. Now. DayOfYear () returns the day of the year when the system is currently
DateTime. Now. Hour () returns the current time of the system
DateTime. Now. Minute () returns the current score of the system.
DateTime. Now. Second () returns the current system Second
DateTime. Now. AddDays () returns the number of days with the value assigned to the current date of the system.
DateTime. Now. AddMonths () returns the number of months added to the current date of the system.
DateTime. Now. AddYears () returns the number of years added to the current date of the system.
DateTime. Now. AddSeconds () returns the second with the value assigned to the system's current date.
DateTime. Now. AddMinutes () returns the score of the value added to the current date of the system.
DateSerial Functions
The DateSerial function returns the date of the value assignment. The format is as follows:
DateSerial (Year, Month, Day)
DateDiff Function
The DateDiff function is used to obtain the interval between two dates and return the gap between the two dates by year, month, and day. The format is as follows:
DateDiff (interval parameter, date 1, date 2)

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.