Class Date
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.Examples
Date d;
print(d.toString());
Constructors
Date(Date)
Pass a value to copy into a new object.
Declaration
Date Date(Date value)
Examples
Date d;
Date next = Date(d);
printLine(next.toString());
Parameters
Type | Name | Description |
Date | value | Date object. |
Type | Description |
Date |
Date(String)
Pass a String containing a date on format YYYY-MM-DD. The constructor will parse the text and create a Date object.
Declaration
Date Date(String value)
Examples
String newYearsDay = "2020-01-01";
Date q1 = Date(newYearsDay);
Parameters
Type | Name | Description |
String | value | A String containing a date (YYYY-MM-DD). |
Type | Description |
Date |
Methods
toString()
Converts a date value to its string representation, in ISO format.
Declaration
String toString()
Examples
Date d;
String s = d.toString();
Returns
Type | Description |
String |
addDay(Integer)
Adjusts the currently set date with the given number of days. The original object will be modified, and a copy is returned.
Declaration
Date addDay(Integer num)
Examples
Date d;
d.addDay(3);
printLine("Three days from now: " + d.toString());
Parameters
Type | Name | Description |
Integer | num | Number of days to add. |
Returns
Type | Description |
Date |
addMonth(Integer)
Adjusts the currently set date with the given number of months.
Declaration
Date addMonth(Integer num)
Examples
Date d;
d.addMonth(3);
printLine("Three months from now: " + d.toString());
Parameters
Type | Name | Description |
Integer | num | Number of months to add. |
Returns
Type | Description |
Date |
addYear(Integer)
Adjusts the currently set date with the given number of years.
Declaration
Date addYear(Integer num)
Examples
Date d;
d.addYear(1);
printLine("A year from now: " + d.toString());
Parameters
Type | Name | Description |
Integer | num | Number of years to add. |
Returns
Type | Description |
Date |
getMDay()
Returns the day of the month as an Integer [1-31].
Declaration
Integer getMDay()
Examples
Date d;
print(d.getMDay().toString());
Returns
Type | Description |
Integer |
getMonth()
Returns the month as an Integer [1-12].
Declaration
Integer getMonth()
Examples
Date d;
print(d.getMonth().toString());
Returns
Type | Description |
Integer |
getWeek()
Returns the ISO number of the week as an Integer [1-53].
Declaration
Integer getWeek()
Examples
Date d;
print(d.getWeek().toString());
Returns
Type | Description |
Integer |
getWeekDay()
Returns the ISO day of the week as an Integer [0-6].
Declaration
Integer getWeekDay()
Examples
Date d;
print(d.getWeekDay().toString());
Returns
Type | Description |
Integer |
getYear()
Returns the year as an Integer.
Declaration
Integer getYear()
Examples
Date d;
print(d.getYear().toString());
Returns
Type | Description |
Integer |
isNull()
Returns true if it has no value and false if it does.
Declaration
Bool isNull()
Examples
Date d;
print(d.isNull().toString());
Returns
Type | Description |
Bool |