The underlying Impala data type for date and time data is
You can also adjust a
Some of these functions are affected by the setting of the
Function reference:
Impala supports the following data and time functions:
Return type:
Same as
The following examples demonstrate adding months to construct the same day of the month in a different month; how if the current day of the month does not exist in the target month, the last day of that month is substituted; and how a negative argument produces a return value from a previous month.
Return type:
The following examples show how to add a number of days to a
Return type:
Return type:
The following example shows the simplest usage, of adding a specified number of days
to a
The following examples show the shorthand notation of an
Like all date/time functions that deal with months,
Return type:
Return type:
The following example shows the simplest usage, of subtracting a specified number of days
from a
The following examples show the shorthand notation of an
Like all date/time functions that deal with months,
Return type:
If the first argument represents a later date than the second argument,
the return value is positive. If both arguments represent the same date,
the return value is zero. The time portions of the
The following example shows how comparing a late
value with
an earlier
value produces a positive number. In this case,
the result is (365 * 5) + 1, because one of the intervening years is
a leap year.
The following examples show how the return value represent the number of days
between the associated dates, regardless of the time portion of each
Return type:
The following examples show how the day value corresponds to the day of the month, resetting back to 1 at the start of each month.
The following examples show how the day value is
Return type:
The following examples show the day name associated with
Return type:
Return type:
The following examples show return values from the
Return type:
Return type:
Unit argument: The
In Impala 2.0 and higher, you can use special syntax rather than a regular function call, for
compatibility with code that uses the SQL-99 format with the
Typically used in
Return type:
Return type:
The format string accepts the variations allowed for the
Currently, the format string is case-sensitive, especially to distinguish
The more flexible format strings allowed with the built-in functions do not change the rules about
using
Return type:
Usage notes: Often used to translate UTC time zone data stored in a table back to the local
date and time for reporting. The opposite of the
See discussion of time zones in
The following example shows how when
The following example shows that for a date and time when daylight savings
is in effect (
Return type:
Return type:
Return type:
Return type:
Typically used in business contexts, for example to determine whether a specified number of months have passed or whether some end-of-month deadline was reached.
The method of determining the number of elapsed months includes some special handling of
months with different numbers of days that creates edge cases for dates between the
28th and 31st days of certain months. See
If either value is
If the first argument represents an earlier time than the second argument, the result is negative.
Return type:
Return type:
Return type:
The millisecond value is truncated, not rounded, if the
Return type:
Return type:
Return type:
Return type:
Return type:
Return type:
Return type:
The following example shows the effects of adding some number of
months to a
The following examples show how if
Return type:
Typically used in business contexts, for example to determine whether a specified number of months have passed or whether some end-of-month deadline was reached.
If the only consideration is the number of full months and any fractional value is
not significant, use
The method of determining the number of elapsed months includes some special handling of months with different numbers of days that creates edge cases for dates between the 28th and 31st days of certain months.
If either value is
If the first argument represents an earlier time than the second argument, the result is negative.
The following examples show how dates that are on the same day of the month are considered to be exactly N months apart, even if the months have different numbers of days.
The following examples show how dates that are on the last day of the month are considered to be exactly N months apart, even if the months have different numbers of days. For example, from January 28th to February 28th is exactly one month because the day of the month is identical; January 31st to February 28th is exactly one month because in both cases it is the last day of the month; but January 29th or 30th to February 28th is considered a fractional month.
The following examples show how dates that are not a precise number of months apart result in a fractional return value.
The following examples show how the time portion of the
Return type:
Return type:
Return type:
Return type:
To find a date/time value in the future or the past relative to the current date
and time, add or subtract an
To produce a
Any references to the
Return type:
Return type:
Return type:
Return type:
The following examples show how to subtract a number of days from a
Return type:
Usage notes: The result value represents similar information as the
The following examples show the format of the
Return type:
Usage notes: A comparison function for
The following examples show all the possible return values for
Return type:
Return type:
Often used in combination with the
See discussion of time zones in
The simplest use of this function is to turn a local date/time value to one with the standardized
UTC time zone. Because the time zone specifier is not saved as part of the Impala
Once a value is converted to the UTC time zone by
Unit argument: The
Typically used in
Because the return value is a
Return type:
The following example shows how the argument
Return type:
See
In Zulu
time, a synonym for UTC.
In
The following examples show different ways of turning the same date and time into an integer value.
A format string that Impala recognizes by default is interpreted as a UTC date and time.
The trailing
The final two examples show how to specify a timezone offset of Pacific Daylight Saving Time, which is 7 hours earlier than UTC.
You can use the numeric offset
Return type:
Return type:
Return type:
Return type:
Return type:
The following example shows how if the equivalent date does not exist in the year of the result due to a leap year, the date is changed to the last day of the appropriate month.
Return type:
The following example shows how if the equivalent date does not exist in the year of the result due to a leap year, the date is changed to the last day of the appropriate month.