Date Functions and Properties
In this Page
- 1 Comparing Dates
- 2 now
- 3 parse
- 4 UTC
- 5 LocalDateTime.parse()
- 6 LocalDate.parse()
- 7 LocalTime.parse()
- 8 Getter Methods
- 8.1 getDate
- 8.2 getDay
- 8.3 getFullYear
- 8.4 getHours
- 8.5 getMilliseconds
- 8.6 getMinutes
- 8.7 getMonth
- 8.8 getMonthfromZero
- 8.9 getUTCMonthfromZero
- 8.10 getSeconds
- 8.11 getTime
- 8.12 getUTCDate
- 8.13 getUTCFullYear
- 8.14 getUTCMonth
- 8.15 getUTCDay
- 8.16 getUTCHours
- 8.17 getUTCMinutes
- 8.18 getUTCSeconds
- 8.19 getUTCMilliseconds
- 8.20 getTimezoneOffset
- 9 Conversion Getter Methods
- 9.1 toString
- 9.2 toLocaleString
- 9.3 toLocaleDateString
- 9.4 toLocaleDateTimeString
- 9.5 toLocaleTimeString
- 10 Date Class Extensions
- 10.1 toLocaleDateString
- 10.2 plus
- 10.3 plusDays
- 10.4 plusHours
- 10.5 plusMillis
- 10.6 plusMinutes
- 10.7 plusMonths
- 10.8 plusSeconds
- 10.9 plusWeeks
- 10.10 plusYears
- 10.11 minus
- 10.12 minusDays
- 10.13 minusHours
- 10.14 minusMillis
- 10.15 minusMinutes
- 10.16 minusMonths
- 10.17 minusSeconds
- 10.18 minusWeeks
- 10.19 minusYears
- 10.20 withDayOfMonth
- 10.21 withDayOfYear
- 10.22 withHourOfDay
- 10.23 withMillisOfSecond
- 10.24 withMinuteOfHour
- 10.25 withMonthOfYear
- 10.26 withSecondOfMinute
- 10.27 withYear
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 UTC. The results are of the date-time data type. This is similar to the JavaScript now. |
|---|---|
Syntax | Date.now() |
Example | Expression: 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:
|
Example | Expression: Result: 2015-10-27T01:47:49.510 (in the server's timezone) Expression: Result: 2011-10-30T00:00:00.000 (in the server's timezone) Expression: Result: 2015-04-15T13:23:10.000 (in the server's timezone) Expression: 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:
|
Example | Expression: Result: 2015-08-20T13:23:12.034 UTC |
LocalDateTime.parse()
Description | Returns the date in local time. |
|---|---|
Syntax | LocalDateTime.parse(_Input_Date) |
Example | Expression: Result: 2011-10-31T00:00:00.000 |
LocalDate.parse()
Description | Returns the date in local time. |
|---|---|
Syntax | LocalDate.parse(_Input_Date) |
Example | Expression: Result: 2011-10-31 |
LocalTime.parse()
Description | Returns the date in local time. |
|---|---|
Syntax | LocalTime.parse(_Input_Time) |
Example | Expression: 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: 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: 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: 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: Result: 125 |
getMinutes
Description | This is similar to the JavaScript getMinutes - returns the minutes in the specified date. |
|---|---|
Syntax | dateobject.getMinutes() |
Example | Expression: 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 | Expression: 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 | Expression: 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 | Expression: 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: 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: 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:
This is similar to the JavaScript toLocaleString. |
|---|---|
Syntax | dateobject.toLocaleString() |
Example | Expressions: |
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2026 SnapLogic, Inc.