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.

...

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 UTC(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: 

...

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)

...