In AskiaScript, a date variable contains date and/or time information.
In this topic:
Assign a date to a variable with the date between hash characters (#), and using the slash character (/) as separator. The format is:
#DD/MM/YYYY#
For example:
dim my_date = #25/03/2011#
Assign a time to a variable with the time between hash characters (#), and using the colon character (:) as separator. The format is:
#HH:MM[:SS]#
For example:
dim my_time = #16:32#
dim my_time = #16:32:07#
Assign a date and time to a variable, with the date and time between hash characters (#). Use the slash character (/) as a separator for the date and the colon character (:) as a separator for the time. The date and time should be separated from each other by a space. The format is:
#DD/MM/YYYY HH:MM[:SS]#
For example:
dim my_date = #25/03/2011 16:32# dim my_date = #25/03/2011 16:32:07#
Returns the day from the specified date, as a number.
Returns a Number.
dim dt = #25/03/2011# dt.Day ' => 25
Returns the month from the specified date, as a number.
Returns a Number.
dim dt = #25/03/2011# dt.Month ' => 3
Returns the year from the specified date, as a number.
Returns a Number.
dim dt = #25/03/2011# dt.Year ' => 2011
Returns the hour from the specified time, as a number.
Returns a Number.
dim tm = #16:32:07# tm.Hour ' => 16
Returns the minute from the specified time, as a number.
Returns a Number.
dim tm = #16:32:07# tm.Minute ' => 32
Returns the second from the specified time, as a number.
Returns a Number.
dim tm = #16:32:07# tm.Second ' => 7
Returns the day of the week (1-7) from the specified date, as a number, where Sunday is day 1:
Returns a Number.
dim dt = #25/03/2011# dt.DayOfWeek ' => 6
Returns the day of the year (1-366) from the specified date, as a number:
Returns a Number.
dim dt = #25/03/2011# dt.DayOfYear ' => 84
Converts the specified date to a number.
Returns a Number.
dim dt= #25/03/2011 16:32:07# dt.ToNumber() ' => 40627.688969907409
Formats the specified date to a string, using the specified format parameter.
Returns a String.
format parameter is case sensitive.
See Date Formatting
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("dd/MM/yyyy") ' => "02/03/2011"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("yyyy-MM-dd") ' => "2011-03-02"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("MM/dd/yyyy") ' => "03/02/2011"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("dd MMM yyyy") ' => "02 Mar 2011"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("dd MMMM yyyy") ' => "02 March 2011"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("MMMM dd, ddd. yyyy") ' => "March 02, Wed. 2011"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("MMMM dd, dddd yyyy") ' => "March 02, Wednesday 2011"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("d-M-yy") ' => "2-3-11"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("dd/MM/yyyy HH:mm") ' => "02/03/2011 16:32"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("dd/MM/yyyy hh:mm") ' => "02/03/2011 04:32"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("dd/MM/yyyy hh:mmampm") ' => "02/03/2011 04:32pm"
dim dt= #02/03/2011 16:32:07# ' March 2nd, 2011
dt.Format("dd/MM/yyyy hh:mm:ssAMPM") ' => "02/03/2011 04:32:07PM"
Converts a date to a string using the regional settings context (using either the language of the respondent, or the current machine).
Returns a String.
Always returns "date".
Returns a String.
dim dt= #12/01/2009# dt.TypeOf() ' => "date"
| Name | Symbol / Expression | Description | Example |
|---|---|---|---|
| Addition | + |
Addition. Returns a date. |
dim i = #25/03/2011 16:32:07# i + 3 ' => #28/03/2011 16:32:07# i + (3/24) ' => #25/03/2011 19:32:07# i + (3/(24*60)) ' => #25/03/2011 16:35:07# i + (3/(24*60*60)) ' => #25/03/2011 16:32:10# Attention: Date + Date = Error |
| Subtraction | - |
Subtraction. Returns a date or a number. |
dim i = #25/03/2011 16:32:07# dim j = #23/05/2010 11:05:58# i - 3 ' => #22/03/2011 16:32:07# i - (3/24) ' => #25/03/2011 13:32:07# i - (3/(24*60)) ' => #25/03/2011 16:29:07# i - (3/(24*60*60)) ' => #25/03/2011 16:32:04# i - j ' => 306.2264930555539 j - i ' => -306.2264930555539 Attention: Date - Number = Date Date - Date = Number |
| Equal | = |
Tests whether two dates are equal. Returns a boolean. To use this operator for comparisons, the condition should be between brackets, or else it will be considered an assignment operator.
|
dim i = #25/03/2011# (i = #24/03/2011#) ' => False (i = #25/03/2011#) ' => True |
| Different | <> |
Tests whether two dates are not equal. Returns a boolean. |
dim i = #25/03/2011# i <> #24/03/2011# ' => True i <> #25/03/2011# ' => False |
| Less than | < |
Tests the relative sizes between two dates. Returns a boolean. |
dim i = #25/03/2011# i < #24/03/2011# ' => False i < #25/03/2011# ' => False i < #26/03/2011# ' => True |
| Less or equal than | <= |
Tests the relative sizes between two dates. Returns a boolean. |
dim i = #25/03/2011# i <= #24/03/2011# ' => False i <= #25/03/2011# ' => True i <= #26/03/2011# ' => True |
| Greater than | > |
Tests the relative sizes between dates. Returns a boolean. |
dim i = #25/03/2011# i > #24/03/2011# ' => True i > #25/03/2011# ' => False i > #26/03/2011# ' => False |
| Greater or equal than | >= |
Tests the relative sizes between two dates. Returns a boolean. |
dim i = #25/03/2011# i >= #24/03/2011# ' => True i >= #25/03/2011# ' => True i >= #26/03/2011# ' => False |
| String | Description |
|---|---|
| yy | Year without the century (00 - 99). |
| yyyy | Year with the century, for example 2000. |
| M | Month number, without a leading zero (1 - 12). |
| MM | Month number, with a leading zero when the number would otherwise have only one digit (01 - 12). |
| MMM | The name of the month as an abbreviation (Jan - Dec). |
| MMMM | The name of month in full (January - December). |
| d | Day of the month, without a leading zero (1 - 31). |
| dd | Day of the month, with a leading zero when the number would otherwise have only one digit (01 - 31). |
| ddd | Name of the day of the week as an abbreviation (Sun - Sat). |
| dddd | Name of the day of the week (Sunday - Saturday). |
| h | Hour, in 12-hour format, without a leading zero (0 - 12). |
| hh | Hour, in 12-hour format, with a leading zero when the hour would otherwise have only one digit (00 - 12). |
| H | Hour, in 24-hour format, without a leading zero (0 - 23). |
| HH | Hour, in 24-hour format, with a leading zero when the hour would otherwise have only one digit (00 - 23). |
| m | Minutes, without a leading zero (0 - 59). |
| mm | Minutes, with a leading zero when the minutes would otherwise have only one digit (00 - 59). |
| s | Seconds, without a leading zero (0 - 59). |
| ss | Seconds, with a leading zero when the seconds would otherwise have only one digit (00 - 59). |
| ampm | Display the "am" string literal with any hour before noon and display the "pm" string literal with any hour between noon and 23:59. |
| AMPM | Display the "AM" string literal with any hour before noon and display the "PM" string literal with any hour between noon and 23:59. |
| [All other characters] | Literal character; displayed as typed. |