Date Functions and Properties

Date Functions and Properties

In this Page

Dates function similarly to Javascript Date objects in which a Date represents the number of milliseconds since midnight January 1, 1970 UTC.

Timestamp formats may differ across different database or APIs. Migrating date information may have unintended results if those differences are not taken into consideration. Time zone settings between Cloudplex and Groundplex might differ since Cloudplex may be in UTC, while a Groundplex could be in a local time zone.

Comparing Dates

Dates can be compared using the relational operators (>, >=, <, <=, ==). For example:

Date.parse("2011-10-10T14:48:00.123-08:00") > Date.parse("2011-10-10T12:48:00.123-08:00") // true // The following is true because a Date is a number of milliseconds since midnight January 1, 1970 UTC Date.parse("2011-10-10T15:48:00.123-08:00") > 1318286880123


The following methods from JavaScript are implemented for Date objects according to local time unless noted otherwise.

now

Description

Returns the current datetime as YYYY-MM-DDTHH:mm:ss.SSS UTCThe results are of the date-time data type.

This is similar to the JavaScript now.

Syntax

Date.now()

Example

Expression: Date.now()

Result: 2017-02-21T21:34:22.025 UTC

parse

Description

Parses a string representation of a date, and returns it as YYYY-MM-DDTHH:mm:ss.SSS that matches the server's timezone. The results are of the date-time data type.

This is similar to the JavaScript parse.

Syntax

Date.parse(dateString)

This method has the following extensions from the standard:

  • parse(millisFromEpoch) - Return a date object that is initialized with the given number of milliseconds from the epoch. If the parameter to parse() is a number, it will be treated as the number of milliseconds from the epoch (Jan 1, 1970) and a new date object will be created and initialized with that value.

  • parse(dateStringformat) - Parse a date string using a custom format. The second argument is a format string using the same syntax as the Java SimpleDateFormat class.

  • parse(dateNumber, format) - Parse a number as a date using a custom format. The second argument is a format string using the same syntax as the Java SimpleDateFormat class. The number converts to a string and parsed using the given format.

Example

Expression: Date.parse(1445910469510)

Result: 2015-10-27T01:47:49.510 (in the server's timezone)



Expression: Date.parse("2011 10 30", "yyyy MM dd")

Result: 2011-10-30T00:00:00.000 (in the server's timezone)



Expression: Date.parse ($['System Modstamp'],"MM/dd/yyyy'T'HH:mm:ss.SSS'Z'")

Result: 2015-04-15T13:23:10.000 (in the server's timezone)



Expression: Date.parse(20160923, “yyyyMMdd”)

Result: 2016-09-23T00:00:00.000 (in the server's timezone)

UTC

Description

Returns the date/time in universal time. The results are of the date-time data type.

This is similar to the JavaScript UTC.

Syntax

Date.UTC(year, month, [day, hour, minute, second, millisecond])

where:

  • year is a year after 1900.

  • month is an integer between 0 and 11 representing the month.

  • day is an optional integer between 1 and 31 representing the day of the month.

  • hour is an optional integer between 0 and 23 representing the hours.

  • minute is an optional integer between 0 and 59 representing the minutes.

  • second is an optional integer between 0 and 59 representing the seconds.

  • millisecond is an optional integer between 0 and 999 representing the milliseconds.

Example

Expression: Date.UTC(2015, 7, 20, 13, 23, 12, 34)

Result: 2015-08-20T13:23:12.034 UTC

LocalDateTime.parse()

Description

Returns the date in local time.

Syntax

LocalDateTime.parse(_Input_Date)

Example

Expression: LocalDateTime.parse("2011-10-31")

Result: 2011-10-31T00:00:00.000

LocalDate.parse()

Description

Returns the date in local time.

Syntax

LocalDate.parse(_Input_Date)

Example

Expression: LocalDate.parse("2011/10/31")

Result: 2011-10-31

LocalTime.parse()

Description

Returns the date in local time.

Syntax

LocalTime.parse(_Input_Time)

Example

Expression: LocalTime.parse("23:42:00")

Result: 23:42:00.000

Getter Methods

getDate

Description

Returns the day of the month for the specified date as an integer between 1 and 31.

This is similar to the JavaScript getDate

Syntax

dateobject.getDate()

Example

Expression: Date.parse("2014-09-22").getDate()

Result: 22

getDay

Description

Returns the day of the week for the specified date as an integer, where 0 represents Sunday.

This is similar to the JavaScript getDay 

Syntax

dateobject.getDay()

Example

Expression: Date.parse("2014-09-22").getDay() 

Result: 1 (indicating Monday)

getFullYear

Description

This is similar to the JavaScript getFullYear - returns the year of the specified date as an integer.

Syntax

dateobject.getFullYear()

Example

Expression: Date.now().getFullYear()

Result: 2017

getHours

Description

This is similar to the JavaScript getHours - returns the hour for the specified date as an integer between 0 and 23.

Syntax

dateobject.getHours()

Example

Expression: Date.now().getHours()

Result: 21

getMilliseconds

Description

This is similar to the JavaScript getMilliseconds - returns the milliseconds in the specified date as an integer.

Syntax

dateobject.getMilliseconds()

Example

Expression: Date.now().getMilliseconds()

Result: 125

getMinutes

Description

This is similar to the JavaScript getMinutes - returns the minutes in the specified date.

Syntax

dateobject.getMinutes()

Example

Expression: Date.now().getMinutes()

Result: 34

getMonth

Description

Returns the month in the specified date as an integer between 1 (January) and 12 (December). This is different from the JavaScript getMonth in that this returns months starting from 1 instead of 0.

Syntax

dateobject.getMonth()

Example

ExpressionDate.parse("2019-03-04T17:32:53.077 UTC").getMonth()

Result: 3

getMonthfromZero

Description

Returns the month in the specified date as an integer between 0 (January) and 11 (December). Unlike getMonth, this expression is similar to the JavaScript getMonth.

Syntax

dateobject.getMonthFromZero()

Example

ExpressionDate.parse("2019-03-04T17:32:53.077 UTC").getMonthFromZero()

Result: 2

getUTCMonthfromZero

Description

Returns the month according to UTC in the specified date as an integer between 0 (January) and 11 (December). This expression is similar to the JavaScript getUTCMonth.

Syntax

dateobject.getUTCMonthfromZero()

Example

ExpressionDate.parse("2019-03-04T17:32:53.077 UTC").getUTCMonthFromZero()

Result: 11, 0

getSeconds

Description

This is similar to the JavaScript getSeconds - returns the seconds in the specified date as an integer between 0 and 59.

Syntax

dateobject.getSeconds()

Example

Expression: Date.now().getSeconds()

Result: 22

getTime

Description

This is similar to the JavaScript getTime - returns the numeric value corresponding to the time for the specified date according to universal time as the number of milliseconds since 1 January 1970 00:00:00 UTC (epoch time). 

Syntax

dateobject.getTime()

Example

Expression: Date.now().getTime()

Result: 1487712862069

getUTCDate

Description

Converts the specified time to its corresponding UTC time

Syntax

dateobject.getUTCDate()

Example

Expression: Date.parse("2019-03-04T17:32:53.077").getUTCDate()

Result: 4

getUTCFullYear

Description

Retrieves the year component from the specified date, according to UTC. Values range from 1000 to 9999

Syntax

dateobject.getUTCFullYear()

Example

Expression: Date.parse("2019-03-04T17:32:53.077").getUTCFullYear()

Result: 2019

getUTCMonth

Description

Retrieves the month component from the specified time, according to UTC. Values range from 1 (January) to 12 (December).

Syntax

dateobject.getUTCMonth()

Example

Expression: Date.parse("2019-03-04T17:32:53.077").getUTCMonth()

Result: 3

getUTCDay

Description

Returns the day of the week for the specified date, according to UTC. Values range from 0 (Sunday) to 6 (Saturday).

Syntax

dateobject.getUTCDay()

Example

Expression: Date.parse("2019-03-04T17:32:53.077").getUTCDay()

Result: 1 (Monday)

getUTCHours

Description

Returns the hour component from the specified date, according to UTC. Values range from 0 to 23.

Syntax

dateobject.getUTCHours()

Example

Expression: Date.parse("2019-03-04T17:32:53.077").getUTCHours()

Result: 17

getUTCMinutes

Description

Returns the minute component from the specified date, according to UTC. Values range from 0 to 59.

Syntax

dateobject.getUTCMinutes()

Example

Expression: Date.parse("2019-03-04T17:32:53.077").getUTCMinutes()

Result: 32

getUTCSeconds

Description

Returns the second component from the specified date, according to UTC. Values range from 0 to 59.

Syntax

dateobject.getUTCSeconds()

Example

Expression: Date.parse("2019-03-04T17:32:53.077").getUTCSeconds()

Result: 53

getUTCMilliseconds

Description

Returns the millisecond component from the specified date, according to UTC. Values range from 0 to 999.

Syntax

dateobject.getUTCMilliseconds()

Example

Expression: Date.parse("2019-03-04T17:32:53.077").getUTCMilliseconds()

Result: 77

getTimezoneOffset

Description

Returns the time difference (in minutes) between the specified time and the UTC time.

Syntax

dateobject.getTimezoneOffset()

Example

Expression: Date.parse("2019-03-04T17:32:53.077").getTimezoneOffset()

Result: 0

Conversion Getter Methods

toString

Description

Returns a string representing the specified Date object.

This is similar to the JavaScript toString.

Syntax

dateobject.toString()

Example

Expression: Date.parse("2014-09-22").toString()

Result: 2014-09-22T00:00:00.000Z

toLocaleString

Description

Returns a string with a language-sensitive representation of the date and time. You can specify the formatting conventions of a given language that should be used and customize the behavior of the function. See Database Date Types for compatible date-related formats when data comes from a database.

The argument to this method is an object containing the following options that control the format of the returned string:

  • format: Describes the format of the returned string. See the Joda DateTimeFormat documentation for the full details.

  • timeZone: Specifies the target time zone. Use the Canonical ID value from Joda-Time.

  • locale: Specifies the language tag.  

This is similar to the JavaScript toLocaleString.

Syntax

dateobject.toLocaleString()

Example

Expressions