Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this Page

...

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

...

Example
Description

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

This is similar to the JavaScript parse.

Syntax


Code Block
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 UTC000 (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 UTC000 (in the server's timezone)


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

Result: 2016-09-23T00:00:00.000000 (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


Code Block
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

...

DescriptionReturns 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


Code Block
dateobject.getMonthFromZero()


Example

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

Result: 2

...

DescriptionReturns 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


Code Block
dateobject.getUTCMonthfromZero()


Example

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

Result: 11, 0

...

DescriptionThis 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


Code Block
dateobject.getTime()


Example

Expression: Date.now().getTime()

Result: 1487712862069

getUTCDate

Description

Converts the specified time to its corresponding UTC time

Syntax


Code Block
dateobject.getUTCDate()


Example

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

Result: 4

...

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


Code Block
dateobject.toLocaleString()


Example

Expressions

Date.now().toLocaleString({"locale":"ar-EG"})

Date.now().toLocaleString({"locale":"fa-IR"})

Date.now().toLocaleString({"locale":"en-US"})

Result: 

...

Description

Returns a string with a language sensitive representation of the date portion of this date. 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.

Note

Earlier versions of this method would accept a JSON-encoded string as the options object. However, due to the performance impact of parsing this string, it is recommended that an object literal be used to pass the options instead. If your Pipeline passes a string argument, a warning will be raised during execution.

This is similar to the JavaScript toLocaleDateString.

Syntax


Code Block
dateobject.toLocaleDateString()


Example

Expression: Date.now().toLocaleDateString()

Result: 2014-09-22


Expression: Date.now().toLocaleDateString({"format":"MM-dd-yyyy"})

Result: 09-22-2014


Expression

Date.now().toLocaleDateString({"locale":"ar-EG"})

Date.now().toLocaleDateString({"locale":"fa-IR"})

Date.now().toLocaleDateString({"locale":"en-US"})


Result

...

Description

Returns a string with a language sensitive representation of the time portion of this date. 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.
Note

Earlier versions of this method would accept a JSON-encoded string as the options object. However, due to the performance impact of parsing this string, it is recommended that an object literal be used to pass the options instead. If your pipeline passes a string argument, a warning will be raised during execution.

This is similar to the JavaScript toLocaleDateTimeString.

Syntax


Code Block
dateobject.toLocaleDateTimeString()


Example

Expression: Date.parse("

2014

2024-

09

03-

22

29").toLocaleDateTimeString()

Result:

2014

 2024-

09

03-

22T00

29T00:00:00.000


Expression:

Date.parse("

2016

2024-03-

17T16

28T16:23:59.825").toLocaleDateTimeString({"timeZone":"US/Eastern", "format":"yyyy-MM-dd HH:mm a"})

Date.now().toLocaleDateTimeString({"locale":"ar-EG"})

Image Added

Result:

2016

2024-03-

17 04

28 12:23 PM


For the {"timeZone":"zoneValue"} option, you can use the Canonical ID value from Joda-Time.


Expression

Date.now().toLocaleDateTimeString({"locale":"ar-EG"})

Date.now().toLocaleDateTimeString({"locale":"fa-IR"})

Date.now().toLocaleDateTimeString({"locale":"en-US"})

Result
Image Modified


toLocaleTimeString

Description

Returns a string with a language-sensitive representation of the time portion of this date. 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.
Note

Earlier versions of this method would accept a JSON-encoded string as the options object. However, due to the performance impact of parsing this string, it is recommended that an object literal be used to pass the options instead. If your pipeline passes a string argument, a warning will be raised during execution.

This is similar to the JavaScript toLocaleTimeString.

Note

Date objects do not support the standard setter methods since they are immutable. Instead, you can use the methods described in the next section to produce a new Date object after adding, subtracting, or replacing one of the fields in the object.




Syntax


Code Block
dateObject.toLocaleTimeString()




Example

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

Result: 00:00:00.000


Expression

Date.now().toLocaleTimeString({"locale":"ar-EG"})

Date.now().toLocaleTimeString({"locale":"fa-IR"})

Date.now().toLocaleTimeString({"locale":"en-US"})

Result



...

toLocaleDateString

Description

Format the date using the given format as described in an object.

Syntax


Code Block
$datetime.toLocaleDateString(format)


Example

Expression: 'JS_SomeFile' + Date.now().toLocaleDateTimeString({"format":"yyyyMMddhhmmss"}) + '.json'

Result: JS_SomeFile20171106112401.json

...

Description

Returns a copy of this datetime with the specified duration added. 

This is similar to the JavaScript plus.

Syntax


Code Block
$datetime.plus(value)


Example

If Date.now() is 2017-11-06T21:48:11.952 UTC

Expression: Date.now().plus(2)

Result: 2017-11-06T21:48:11.954 UTC 

(last digit increased by 2)


Expression: Date.now().plus(20)

Result2017-11-06T21:48:11.972 UTC

(second to last digit increased by 2)


Expression: Date.now().plus(2000)

Result2017-11-06T21:48:13.952 UTC

(fourth digit from the end increased by 2)

plusDays

Description

Returns a copy of this datetime plus the specified number of days. 

This is similar to the JavaScript plusDays.

Syntax


Code Block
$datetime.plusDays(value)


Example

If Date.now() is 2017-11-06T21:48:11.952 UTC

Expression: Date.now().plusDays(2)

Result: 2017-11-08T21:48:11.952 UTC

(day value increased by 2)

plusHours

Description

Returns a copy of this datetime plus the specified number of hours. 

This is similar to the JavaScript plusHours.

Syntax


Code Block
$datetime.plusHours(value)


Example

If Date.now() is 2017-11-06T21:48:11.952 UTC

Expression: Date.now().plusHours(2)

Result: 2017-11-06T23:48:11.952 UTC

(hour increased by 2)

...