Date and time functions

This section describes the following date and time functions:

  • ADD_TIME_ZONE_OFFSET: Add a timezone offset to a date. The timezone offset can be in any of the standard formats accepted by Java's ZoneId.of method (America/New_York, +02:00, etc.)

  • DATE: Casts String to Date

  • DATE_ADD: Adds an interval value of type unit to timestamp. Subtraction can be performed by using a negative value

  • DATE_DIFF: Returns timestamp2 - timestamp1 expressed in terms of unit

  • DATE_TRUNC: Truncate a date to a given unit

  • DAY: Returns the day of the month from timestamp

  • DAY_OF_WEEK: Returns the ISO day of the week from timestamp. values range from 1 (Monday) to 7 (Sunday).

  • DAY_OF_YEAR: Returns the day of the year from timestamp. values range from 1 to 366.

  • EXTRACT_TIMESTAMP: Convert a date or timestamp string to a date or timestamp, autodetecting the date format.

  • FORMAT_DATETIME: Convert datetime into string

  • FROM_ISO8601_DATE: Parses the ISO 8601 formatted string into a date

  • FROM_UNIXTIME: Convert epoch seconds to a timestamp

  • HOUR: Returns the hour of the day from timestamp. values range from 0 to 23.

  • MILLISECOND: Returns the millisecond of the second from timestamp

  • MINUTE: Returns the minute of the hour from timestamp

  • MONTH: Returns the month of the year from timestamp

  • QUARTER: Returns the quarter of year from timestamp. Values range from 1 to 4.

  • RUN_END_TIME: gets the job's execution end time

  • RUN_START_TIME: gets the job's execution start time

  • SECOND: Returns the second of the minute from timestamp

  • SUBTRACT_TIME_ZONE_OFFSET: Subtract a timezone offset from a date. The timezone offset can be in any of the standard formats accepted by Java's ZoneId.of method (America/New_York, +02:00, etc.)

  • TO_UNIXTIME: Convert a date to its Epoch (unix) seconds representation, with fractional milliseconds

  • TO_UNIX_EPOCH_MILLIS: Convert a date to it's Epoch (unix) seconds representation

  • TO_UNIX_EPOCH_SECONDS: Convert a date to it's Epoch (unix) seconds representation

  • WEEK: Returns the ISO week of the year from timestamp. Values range from 1 to 53.

  • YEAR_OF_WEEK: Returns the year of ISO week from timestamp

  • YEAR: Returns the year from timestamp

Last updated