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)