Overview Date and Time Keywords
Date
DateAdd
DateD
DateDay
DateDayOfWeek
DateDayOfYear
DateFormat
DateM
DateMonth
DateParse
DateY
DateYear
Now
Time
TimeAdd
TimeFormat
TimeH
TimeHour
TimeM
TimeMinute
TimeParse
TimeS
TimeSecond
Overview Date and Time Keywords Top
Time and date values are stored as their number of "Ticks" since January 1, AD 0001.
Each tick is 1/1,000,000 of a second.
Keyword Date returns a date string from a ticks value.
Keyword Time returns a time string from a ticks value.
Date and Time are formatted using DateFormat and TimeFormat keywords.
You can use TimeAdd / DateAdd or the time and date constants to do time and date manipulation.
The keywords DateD, DateM, DateY, TimeH, TimeM, TimeS are kept for backwards compatibility but are not as powerful as the new date and time keywords.
Date Top
Return a date string from a ticks value.
Syntax: Date (Ticks)
Example:
Msgbox (Date(Now))
Displays the current date.
DateAdd Top
Returns the ticks value of the given ticks + years + months + days.
Syntax: DateAdd (Ticks, Years, Months, Days)
Example:
x = Now
tomorrow = DateAdd(x, 0, 0, 1)
DateD Top
Returns the system day.
Example:
Msgbox (DateM & "/" & DateD & "/" & DateY)
Result: Displays the current date (9/6/2005)
DateDay Top
Returns the day (starting from the beginning of the month) component from a ticks value.
Syntax: DateDay (Ticks)
DateDayOfWeek Top
Returns the name of the day in the week from a ticks value.
Syntax: DateDayOfWeek (Ticks)
DateDayOfYear Top
Returns the day (starting from the beginning of the year) component from a ticks value.
Syntax: DateDayOfYear (Ticks)
DateFormat Top
Changes the format of showing and parsing dates.
Syntax: DateFormat (Format String)
Default value is: "mm/dd/yyyy" (If you do not use the DateFormat keyword then the date format will be this value.)
Example:
x = DateParse ("04/25/2006")
DateFormat ("dddd - mmmm - yy")
Msgbox(Date(x))
This example will show: Tuesday - April - 06
DateM Top
Returns the system month.
Example:
Msgbox (DateM & "/" & DateD & "/" & DateY)
Result: Displays the current date (9/6/2005)
DateMonth Top
Returns the month (starting from the beginning of the year) component from a ticks value.
Syntax: DateMonth (Ticks)
DateParse Top
Returns the ticks value of a date string.
The date string must be formatted exactly as the date format. (Default "mm/dd/yyyy")
Syntax: DateParse (Date String)
Example:
T = DateParse ("01/30/2012")
DateY Top
Returns the system year.
Example:
Msgbox (DateM & "/" & DateD & "/" & DateY)
Result: Displays the current date (9/6/2005)
DateYear Top
Returns the year component from a ticks value.
Syntax: DateYear (Ticks)
Now Top
Returns the ticks value of the current date and time.
Syntax: Now
Example:
Msgbox(Date(Now)) 'Shows the current date formatted as a date string
Time Top
Return a time string from the ticks value.
Syntax: Time (Ticks)
Example:
Msgbox (Time (Now))
Displays the current time.
TimeAdd Top
Returns the ticks value of the given ticks + hours + minutes + seconds.
Syntax: TimeAdd (Ticks, Hours, Minutes, Seconds)
Example:
x = Now
tomorrow = TimeAdd(x, 24, 0, 0)
TimeFormat Top
Changes the format of showing and parsing times.
Syntax: TimeFormat (Format String)
Default value is: "HH:mm" (If you do not use the TimeFormat keyword then the time format will be this value.)
"H" - 24 hours format.
"h" - 12 hours format.
"tt" - AM / PM
TimeFormat can be used any number of times inside an application.
Example:
TimeFormat ("HH:mm:ss")
x = TimeParse ("23:15:23")
TimeFormat ("hh:mm tt")
Msgbox(Time(x))
This example will show: 11:15 PM
TimeH Top
Returns the system hour.
Example:
Msgbox (TimeH & ":" & TimeM & ":" & TimeS)
Result: Shows the current system time.
TimeHour Top
Returns the hour (starting from the beginning of the day) component from the ticks value.
Syntax: DateHour (Ticks)
TimeM Top
Returns the system minutes.
Example:
Msgbox (TimeH & ":" & TimeM & ":" & TimeS)
Result: Shows the current system time.
TimeMinute Top
Returns the minute (starting from the beginning of the hour) component from the ticks value.
Syntax: DateMinute (Ticks)
TimeParse Top
Returns the ticks value of the time string.
The time string must be formatted exactly as the time format. (Default "HH:mm")
Syntax: TimeParse (Time String)
The value returned is the time entered and the current date.
Example:
T = TimeParse ("21:34")
TimeS Top
Returns the system seconds.
Example:
Msgbox (TimeH & ":" & TimeM & ":" & TimeS)
Result: Shows the current system time.
TimeSecond Top
Returns the second (starting from the beginning of the minute) component from the ticks value.
Syntax: DateSecond (Ticks)