Dynamic | function | date | example | Web page function Syntax Express example
Now () gets the current date and time of the system Dim MyVar MyVar = Today
' MyVar contains the current date and time.
Date date () Gets the system's current date Dim mydate mydate = Date
' MyDate contains the current system date.
Time times () to get the system's current mytime Dim mytime = Hour
"Returns the current system time.
Year years (date) Gets the vintage of the given date Dim mydate, myyear
MyDate = #October 19, 1962#
An example of the function syntax
Now () gets the current date and time of the system Dim MyVar MyVar = Today
' MyVar contains the current date and time.
Date date () Gets the system's current date Dim mydate mydate = Date
' MyDate contains the current system date.
Time times () to get the system's current mytime Dim mytime = Hour
"Returns the current system time.
Year years (date) Gets the vintage of the given date Dim mydate, myyear
MyDate = #October 19, 1962#
"Assign a date."
Myyear = year (mydate)
The "Myyear" contains 1962.
Month Month (date) Gets the month Dim MyVar MyVar = Month (now) for the given date
' MyVar contains the number corresponding to the current month.
Day (date) Gets the number of the given date Dim myday myday = Days ("October 19, 1962")
The "Myday" contains 19.
Hour Hour (time) Gets the first few hours of Dim MyTime, Myhour
MyTime = Now Myhour = Hour (mytime)
' Myhour contains a numeric value representing the current time.
Minute Minute (time) Gets the first few minutes of Dim MyVar
MyVar = Minute (now)
Second Second (Time) is the first few seconds Dim mysec
Mysec = Second (now)
' Mysec contains the number representing the current second.
Weekday Weekday (date) Gets the integer for the given date of the week, 1 for Sunday, 2 for Monday, and so on Dim mydate, Myweekday
MyDate = #October 19, 1962#
' Dispatch date
Myweekday = Weekday (mydate)
' Myweekday contains 6,mydate representative Friday
DateDiff DateDiff ("Var", VAR1,VAR2)
Var: Date or time interval factor with the following parameters:
YYYY m month D Day WW Week H S SEC Var1: first date or time
VAR2: The second date or time, which calculates the interval of two dates or times Var1 late DateDiff ("D", date (), #1/1/2005#)
"Back to 2005 New Year's Day how much more
DateDiff ("H", Date (), #1/1/2005#)
"Back to 2005 New Year's Day and how many hours
DateDiff ("D", #1/1/2003#, #1/1/2005#)
"Returns the number of days between two dates
DateAdd DateDiff ("Var", VAR1,VAR2)
Var: Date or time interval factor:
VAR1: Date or time interval multiple
VAR2: Date or time of reference to two dates or times add the following example adds one months to January 31, 95:
Newdate = DateAdd ("M", 1, "31-jan-95")
In this example, 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.
If the calculated date is before 100 A.D., an error is generated.
FormatDateTime FormatDateTime (date,vbshortdate) into Short date format fromatdatetime (date (), vblongdate)
"Display in Long date format
FormatDateTime (date,vblongdate) into a long date format
FormatDateTime (Date,vbshorttime) into a short time format
FormatDateTime (Date,vblongtime) into a long time format
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.