...
Valid casts to/from Date type | Result |
---|---|
cast(date as date) | Same date value |
cast(timestamp as date) | The year/month/day of the timestamp is determined, based on the local timezone, and returned as a date value. |
cast(string as date) | If the string is in the form 'YYYY-MM-DD', then a date value corresponding to that year/month/day is returned. If the string value does not match this formate, then NULL is returned. |
cast(date as timestamp) | A timestamp value is generated corresponding to midnight of the year/month/day of the date value, based on the local timezone. |
cast(date as string) | The year/month/day represented by the Date is formatted as a string in the form 'YYYY-MM-DD'. |
Anchor | ||||
---|---|---|---|---|
|
Intervals
Supported interval description | Example | meaning | since |
---|---|---|---|
Intervals of time units: SECOND / MINUTE / DAY / MONTH / YEAR | INTERVAL '1' DAY | an interval of 1 days | Hive 1.2.0 (HIVE-9792). |
Year to month intervals, format: SY-M S:optional sign(+/-) | INTERVAL '1-2' YEAR TO MONTH | shorthand for: INTERVAL '1' YEAR + | Hive 1.2.0 (HIVE-9792). |
Day to second intervals, format: SD H:M:S.nnnnnn S:optional sign(+/-)D: day countH: hours M:minutes S:seconds nnnnnn: optional nanotime | INTERVAL '1 2:3:4.000005' DAY | shorthand for: INTERVAL '1' DAY+ INTERVAL '2' HOUR + INTERVAL '3' MINUTE + INTERVAL '4' SECOND + INTERVAL '5' NANO | Hive 1.2.0 (HIVE-9792). |
Support for intervals with constant numbers | INTERVAL 1 DAY | aids query readability/portability | Hive 2.2.0 (HIVE-13557). |
Support for intervals with expressions: it may involve other functions/columns The expression must return with an number (which is not floatingpoint) or with a string. | INTERVAL (1+dt) DAY | enables dynamic intervals | Hive 2.2.0 (HIVE-13557). |
Optional usage of interval keyword | 1 DAY | INTERVAL 1 DAY | Hive 2.2.0 (HIVE-13557). |
Add timeunit aliases to aid portability / readability. SECONDS / MINUTES / HOURS / DAYS / MONTHS / YEARS | 2 SECONDS | 2 SECOND | Hive 2.2.0 (HIVE-13557). |
Decimals
Info | ||
---|---|---|
| ||
Decimal datatype was introduced in Hive 0.11.0 (HIVE-2693) and revised in Hive 0.13.0 (HIVE-3976). |
...