Skip to main content
Date is a complex data type representing a day, month, and year on ISO format YYYY-MM-DD. The default value is now. Before a Date is initialized, it has no value. This is commonly written as NULL, NUL, or NIL in other programming languages. CRMScript automatically initializes Date objects when declared to the current date. Thus this situation is uncommon.

Constructors

Date()

Default constructor.

Date(Date)

Pass a value to copy into a new object.

Date(String)

Pass a String containing a date on format YYYY-MM-DD. The constructor will parse the text and create a Date object.

Methods

toString()

Converts a date value to its string representation, in ISO format.
Returns: CRMScript.Global.String
One of the most frequently used methods, typically when you are going to output something.
Example:

addDay(Integer)

Adjusts the currently set date with the given number of days. The original object will be modified, and a copy is returned.
Returns: CRMScript.Global.Date
If the number is negative, the days are subtracted.
Example:

addMonth(Integer)

Adjusts the currently set date with the given number of months.
Returns: CRMScript.Global.Date
The day remains unchanged regardless of the number of days in the months added or subtracted. However, if the update would result in February 29th in a year that is not a leap year, CRMScript automatically corrects it to March 1st.
Example:

addYear(Integer)

Adjusts the currently set date with the given number of years.
Returns: CRMScript.Global.Date
The original object will be modified, and a copy is returned.
Example:

getMDay()

Returns the day of the month as an Integer [1-31].
Returns: CRMScript.Global.Integer Example:

getMonth()

Returns the month as an Integer [1-12].
Returns: CRMScript.Global.Integer Example:

getWeek()

Returns the ISO number of the week as an Integer [1-53].
Returns: CRMScript.Global.Integer
See http://en.wikipedia.org/wiki/ISO_8601 for detailed info on ISO week numbers.
Example:

getWeekDay()

Returns the ISO day of the week as an Integer [0-6].
Returns: CRMScript.Global.Integer
The 1st day of the week is Monday and has index 0!
Example:

getYear()

Returns the year as an Integer.
Returns: CRMScript.Global.Integer Example:

isNull()

Returns true if it has no value and false if it does.
Returns: CRMScript.Global.Bool
A NULL/NUL/NIL Date is different from zero, in that it is conceptually without a value.
Example: