Example of date and time function of asp
You can use the date and time functions to get date and time in various formats
| function | grammar | illustrate | Example |
| Now | Now() | Get the current date and time of the system | Dim MyVar MyVar = Now' MyVar contains the current date and time. |
| Date | Date() | Get the current date of the system | Dim MyDate MyDate = Date' MyDate contains the current system date. |
| Time | Time() | Get the current time of the system | Dim MyTime MyTime = Time' Return to the current system time. |
| Year | Year(Date) | Get the year for the given date | Dim MyDate, MyYearMyDate = #October 19, 1962# 'Distribute one date. ' MyYear contains |
| Month | Month(Date) | Get the month of the given date | Dim MyVar MyVar = Month(Now)' MyVar contains the number corresponding to the current month. |
| Day | Day(Date) | What is the given date | Dim MyDay MyDay = Day("October 19, 1962") 'MyDay contains |
| Hour | Hour(time) | What hour is it to obtain a given time | Dim MyTime, MyHourMyTime = Now MyHour = Hour(MyTime) ' MyHour contains the value representing the current time. |
| Minute | Minute(time) | What is the minute to obtain a given time | Dim MyVarMyVar = Minute(Now) |
| Second | Second(time) | What is the second time to get the guard | Dim MySecMySec = Second(Now) 'MySec contains the number representing the current second. |
| WeekDay | WeekDay(Date) | Get an integer whose given date is the day of the week, 1 means Sunday, 2 means Monday, and so on | Dim MyDate, MyWeekDayMyDate = #October 19, 1962# ' Distribution date ' |
| DateDiff | DateDiff("Var",Var1,Var2) Var: Date or time interval factor, with the following parameters: yyyy year m month d day ww week h hour s seconds Var1: The first date or time Var2: The second date or time, later than Var1 | Calculate the interval between two dates or times | DateDiff("d",Date(),#1/1/2005#) 'How many are there to go before New Year's Day 2005 DateDiff("h",Date(),#1/1/2005#) 'How many hours are there to go back to New Year's Day 2005 DateDiff("d",#1/1/2003#,#1/1/2005#) 'Return 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: The benchmark for date or time | Add two dates or times | The following example adds January 31, 2019:
Related Articles
|