Vybe Documentation
Vybe Main page
Date & Time Functions
The following functions provide capabilities for date and time manipulation, formatting, and calculation.
| Function | Syntax | Description |
|---|---|---|
| Now | Now() |
Returns the current system date and time as a string. |
| Date | Date() |
Returns the current system date as a string. |
| Time | Time() |
Returns the current system time as a string. |
| Year | Year([date]) |
Returns an integer representing the year. |
| Month | Month([date]) |
Returns an integer representing the month (1-12). |
| Day | Day([date]) |
Returns an integer representing the day of the month (1-31). |
| Hour | Hour([time]) |
Returns an integer representing the hour (0-23). |
| Minute | Minute([time]) |
Returns an integer representing the minute (0-59). |
| Second | Second([time]) |
Returns an integer representing the second (0-59). |
| Timer | Timer() |
Returns the number of seconds since midnight. |
| DateAdd | DateAdd(interval, number, date) |
Returns a Date containing a date to which a specified time interval has been added. |
| DateDiff | DateDiff(interval, date1, date2) |
Returns a Long value specifying the number of time intervals between two Date values. |
| DatePart | DatePart(interval, date) |
Returns an Integer containing the specified part of a given Date value. |
| DateSerial | DateSerial(year, month, day) |
Returns a Date value representing a specified year, month, and day. |
| TimeSerial | TimeSerial(hour, minute, second) |
Returns a Date value representing a specified hour, minute, and second. |
| DateValue | DateValue(date) |
Returns a Date value containing the date information represented by a string. |
| TimeValue | TimeValue(time) |
Returns a Date value containing the time information represented by a string. |
| MonthName | MonthName(month, [abbreviate]) |
Returns a string containing the name of the specified month. |
| Weekday | Weekday(date) |
Returns an integer representing the day of the week (1=Sunday). |
| WeekdayName | WeekdayName(weekday, [abbrev]) |
Returns a string containing the name of the specified weekday. |
Examples
' Get current year
Dim currentYear As Integer
currentYear = Year(Now())
' Calculate days between dates
Dim days As Long
days = DateDiff("d", "01/01/2024", "12/25/2024")
' Add 2 weeks to a date
Dim nextMeeting As Date
nextMeeting = DateAdd("ww", 2, Now())
' Get long month name
Dim monthName As String
monthName = MonthName(Month(Now())) ' e.g., "February"
Intervals (DateAdd, DateDiff, DatePart)
| Interval | Description |
|---|---|
"yyyy" |
Year |
"q" |
Quarter |
"m" |
Month |
"y" |
Day of year |
"d" |
Day |
"w" |
Weekday |
"ww" |
Week |
"h" |
Hour |
"n" |
Minute |
"s" |
Second |