Functions are a function block encapsulated by the language to facilitate user calls. For example, "now()" is a function in VBScript that can display the current date and time. As for the specific reason why it can be displayed, it is determined by the language kernel. Users only need to understand that "now()" is used to display dates and time. So, do we have any other functions of VBScript we are currently in contact with?
1. Date/time function
These functions include displays of "year", "month", "day", "hour", "minute", "second", "week", etc.
(1) Now function: Return the current date and time value based on the date and time set by the computer system. Use method now();
(2) Date function: only returns the date value set by the current computer system. How to use: date();
(3) Time function: only returns the time value set by the current computer system. How to use: time();
(4) Year function: Return an integer representing a certain year. Usage method: year(date), where the date parameter is any parameter that can represent a date. For example, "year(date())" means that the integer of "year" is extracted from the date derived from "date()".
In addition, it can also be applied like this: "year(#5 20,2006#)" means extracting the integer value of "year" in "May 20, 2006". Regarding "5 20,2006", "5-20-2006", "5/20/2006" and other forms can also be expressed, that is, a combination of "a certain month, a certain day" and "a certain year". Also note that using "#" is used to include it to represent the date value.
(5) Month function: Returns an integer value between 1 and 12, representing a month of the year. How to use: month(date). The description about parameter date is the same as the year function. But pay attention to the correctness of the date. For example, "#13-31-2006#", there is no "13" month at all, which is definitely wrong.
(6) Day function: Returns an integer value between 1 and 31, indicating a day of a month. How to use: day(date). The description about parameter date is the same as the year function. Also pay attention to the correctness of the date, for example, "#2-30-2006#", the day "30" defined for "February" is wrong.
(7) Hour function: Returns an integer value between 0 and 23, indicating an hour of the day. How to use: hour(time). Where the parameter time is any expression that can represent time. For example, "hour(time())" means that the integer of "hour" is extracted from the time derived from "time()". Similarly, the parameter time can also be used in this way "hour(#11:45:50#)" to indicate the current number of hours from "45" minutes and "50" seconds at "11". Of course, the defined time must comply with the time specifications.
(8) Minute function: Returns an integer value between 0 and 59, representing a certain minute in an hour. How to use: minute(time). The description of time parameter is the same as the hour function.
(9) Second function: Returns an integer value between 0 and 59, representing a certain second in a minute. How to use: second(time). The description of time parameter is the same as the hour function.
(10) Weekday function: Returns the integer of a day of the week. How to use: weekday(date). The description about parameter date is the same as the year function. The return values of this function are "1" to "7", representing "Sunday", "Monday" and "Saturday". For example, when the return value is "4", it means "Wednesday".