Interval Constructors

MICROSECONDS

MICROSECONDS(n) Constructs a microsecond_interval value that refers to a duration of n microseconds.

SELECT TYPEOF(MICROSECONDS(1000000))
'microsecond_interval'
SELECT TIME '10:10:10' + MICROSECONDS(1000000)
10:10:11

MILLISECONDS

MILLISECONDS(n) Constructs a microsecond_interval value that refers to a duration of n milliseconds.

SELECT TYPEOF(MILLISECONDS(1000))
'microsecond_interval'
SELECT TIME '10:10:10' + MILLISECONDS(1000)
10:10:11

SECONDS

TIMESTAMP_SECONDS(n) Constructs value of type timestamp from n seconds since the Unix epoch.

SELECT TYPEOF(SECONDS(1))
'microsecond_interval'
SELECT TIME '10:10:10' + SECONDS(1)
10:10:11

MINUTES

MINUTES(n) Constructs a microsecond_interval value that refers to a duration of n minutes.

SELECT TYPEOF(MINUTES(1))
'microsecond_interval'
SELECT TIME '10:10:10' + MINUTES(1)
10:11:10

HOURS

HOURS(n) Constructs a microsecond_interval value that refers to a duration of n hours.

SELECT TYPEOF(HOURS(1))
'microsecond_interval'
SELECT TIME '10:10:10' + HOURS(1)
11:10:10

DAYS

DAYS(n) Constructs a microsecond_interval value that refers to a duration of n days.

SELECT TYPEOF(DAYS(1))
'microsecond_interval'
SELECT DATE '2019-08-17' + DAYS(1)
2019-08-18T

MONTHS

MONTHS(n) Constructs a month_interval value that refers to a duration of n months.

SELECT TYPEOF(MONTHS(1))
'month_interval'
SELECT DATE '2019-08-17' + MONTHS(1)
2019-09-17

YEARS

YEARS(n) Constructs a month_interval value that refers to a duration of n years.

Constructs a month_interval value that refers to a duration of n years.

SELECT TYPEOF(YEARS(1))
'month_interval'
SELECT DATE '2019-09-17' + YEARS(1)
2020-09-17

PARSE_DURATION_SECONDS

PARSE_DURATION_SECONDS(s) Parses a microsecond_interval value from a string.

Supported formats are:

  • [-]HH:MM:SS[.nnnnnn]
  • [-]MM:SS[.nnnnnn]
  • [-]SS[.nnnnnn]
SELECT PARSE_DURATION_SECONDS('10:23.1')
{"__rockset_type": "MICROSECOND_INTERVAL", "value": 623100000}
SELECT TYPEOF(PARSE_DURATION_SECONDS('10:23.1'))
'microsecond_interval'
SELECT DATETIME '2018-05-26T10:30:20.345' + PARSE_DURATION_SECONDS('10:23.1')
2018-05-26T10:40:43.445

PARSE_DURATION_MONTHS

PARSE_DURATION_MONTHS(s) Parses a month_interval value from a string.

Supported formats are:

  • [-]Y-M
  • [-]M
SELECT PARSE_DURATION_MONTHS('1-1')
{"__rockset_type": "MONTH_INTERVAL", "value": 13}
SELECT TYPEOF(PARSE_DURATION_MONTHS('1-1'))
'month_interval'
SELECT DATETIME '2018-05-26T10:30:20.345' + PARSE_DURATION_MONTHS('1-1')
2019-06-26T10:30:20.345