You are viewing content for 5.1 | 5.0 | 4.9 | 4.8 | 4.7 | 4.6 | 4.5 | 4.4 | 4.3 | Previous Releases


Date Functions

Functions Adding or Subtracting Time From a Date

Function Syntax Description
addMilliseconds() addMilliseconds(date expr d, int s) Returns the sum of d and s seconds as a date value
addSeconds() addSeconds(date expr d, int s) Returns the sum of d and s seconds as a date value
addMinutes() addMinutes(timestamp expr t, int min) Returns a modified date after the specified minutes have been added
addHours() addHours(date expr d, int h) Returns the sum of d and h as a date value
addDays() addDays(timestamp expr t, int days) Returns a new date after adding an integer number of days to a given date
addMonths() addMonths(date expr d, int mos) Returns the sum of d and mos as a date value
addYears() addYears(date expr d, int y) Returns the sum of d and y as a date value
Function Syntax Description
date() date(string expr s_date) Returns a date value converted from a string
formatDate() formatDate(timestamp expr t, string format) Returns the date as a string formatted according to specification

Functions for Returning Time Field Values from Strings and Timestamps

Function Syntax Description
minute() minute([date | timestamp] expr t) Returns the minute field of a date or timestamp value
hour() hour(timestamp expr t) Returns the hour field of a date or timestamp value
day() day(date expr d) Returns the day of the month
month() month([date | timestamp] expr t) Returns the month field of a date or timestamp value
year() year([date | timestamp] expr t) Returns the year field of a date or timestamp value

Functions for Returning the Interval Between Two Times

Function Syntax Description
daysBetween daysBetween(day1, day2) Returns the number of days between two dates, day1 and day2
timeBetween timeBetween(timestamp endTime, timestamp startTime) Returns the interval between two given times, endTime and startTime

Functions for Returning Day or Month Number from a Timestamp or Date Value

Function Syntax Description
weekday() weekday([date | timestamp] expr t) Returns the day number of the week from a day/time string
weeknum() weeknum(timestamp expr t) Returns the week number from the year in the argument

Miscellaneous Functions

Function Syntax Description
removeTime() removeTime(timestamp expr t) Returns a timestamp value with the time fields removed
ifNull() ifNull(exp1, exp2) Returns one of two expressions depending on the first argument
dateTrunc() dateTrunc(date expr d, string part) Returns d truncated to part units
formatDuration() formatDuration() Converts a time value into a duration
© Incorta, Inc. All Rights Reserved.