Home > other >  Hive time
Hive time

Time:09-18

Fixed date into a timestamp
The select unix_timestamp (' 2016-08-16 ', '- dd yyyy - MM) - 1471276800
The select unix_timestamp (' 20160816 ', 'yyyyMMdd') - 1471276800
The select unix_timestamp (' 2016-08-16 T10:02:41 Z ', "yyyy - MM - dd 'T' HH: MM: ss 'Z'") - 1471312961

16/Mar 2017:12:25:01 + 0800 to normal format (MM - dd yyyy - hh: MM: ss)
The select from_unixtime (to_unix_timestamp (' 16/Mar 2017:12:25:01 + 0800 ', 'dd/MMM yyy: HH: mm: ss Z'))

The timestamp conversion process fixed date
The select from_unixtime (1471276800, '- dd yyyy - MM) - 2016-08-16
The select from_unixtime (1471276800, 'yyyyMMdd') - 20160816
The select from_unixtime (1471312961) - the 2016-08-16 10:02:41
The select from_unixtime (unix_timestamp (' 20160816 ', 'yyyyMMdd'), '- dd yyyy - MM) - 2016-08-16
The select date_format (' 2016-08-16 ', 'yyyyMMdd') - 20160816

Returns the date of the date/time field part
Select to_date (' 2016-08-16 10:03:01) - 2016-08-16
Get the current time
The select from_unixtime (unix_timestamp (), 'MM - dd yyyy - HH: MM: ss')
The select from_unixtime (unix_timestamp (), '- dd yyyy - MM)
In the return date years
Select year (' 2016-08-16 10:03:01) - 2016
In the return date
Select the month (' 2016-08-16 10:03:01) - 8
In the return date,
Select day (' 2016-08-16 10:03:01) - 16
When the return date
Select hour (' 2016-08-16 10:03:01) - 10
The portion of return date
The select minute (' 2016-08-16 10:03:01) - 3
Return date of the second
Select the second (' 2016-08-16 10:03:01) - 1

Return date in the current number of weeks
Select weekofyear (' 2016-08-16 10:03:01) - 33

Return the number of days end date minus the start date
The select datediff (' 2016-08-16 ', '2016-08-11')

Return to the starting date startdate increase days days after the date of the
The select date_add (' 2016-08-16 ', 10)

Return to the starting date startdate reduce days days after the date of the
The select date_sub (' 2016-08-16 ', 10)

Back on the day of the three ways
The SELECT CURRENT_DATE;
- 2017-06-15
The SELECT CURRENT_TIMESTAMP. Returned - minutes
- the 2017-06-15 19:54:44
The SELECT from_unixtime (unix_timestamp ());
- the 2017-06-15 19:55:04
Returns the current timestamp
Select current_timestamp 10:37:53-2018-06-18. 278

Return on the first day of that month
The select trunc (' 2016-08-16 ', 'MM) - 2016-08-01
The first day of the return to the
The select trunc (' 2016-08-16 ', 'YEAR') - 2016-01-01
  • Related