get current UNIX timestamp function : Unix_timestamp syntax: Unix_timestamp ()
return value: bigint
Description: Gets the UNIX timestamp for the current time zone
Example:
Hive>Select from dual; OK 1455616811 0.7851 row (s)
Date function Unix timestamp to date function : from_unixtime
Syntax: From_unixtime (bigint unixtime[, string format])
return value: String
Description: Convert Unix timestamp (from 1970-01-01 00:00:00 UTC to the number of seconds in the specified time) to the time format of the current time zone
Example:
hive> select From_unixtime ( Span style= "color: #800000; Font-weight:bold; " >1455616811 , yyyymmdd ' ) from Dual;ok 20160216 time taken: 0.221 seconds, fetched: 1 Row (s)
date to Unix timestamp function : Unix_timestamp Syntax: Unix_timestamp (string date)
example:
hive> select Unix_timestamp ( Span style= "color: #ff0000;" > '
specify format date to UNIX timestamp function : Unix_timestamp Syntax: unix_timestamp (string date, string pattern)
return value: bigint
example:
Hive>Select unix_timestamp ('20160216 14:02:03',' YYYYMMDD HH:mm:ss' from dual;ok14556025230.21 1 Row (s)
Date time to date function : to_date
syntax: to_date (string timestamp)
return value: string
Span style= "font-family: Song body; font-size:12px; " > Description: Returns the date part in the Date Time field.
example:
Hive>Select to_date ('2016-02-16 14:02:03' from dual;o K-Geneva- 0.222 1 row (s)
date following year function : Year
Syntax: Year (string date)
return value: int
Description: Returns the year of the date.
Example:
Hive>Selectyear ('2016-02-16 14:02:03' from Dual;ok . 0.2551 row (s)
Hive>Selectyear ('2016-02-16' from Dual;ok 0.325 1 row (s)
Date-to- month function : month
Syntax: Month (string date)
return value: int
Description: Returns the month of the date.
Example: Ibid.
Date function: Day
Syntax: Day (string date)
return value: int
Description: Returns days in the date.
Example: Ibid.
date to hour function : Hour
Syntax: Hour (string date)
return value: int
Description: Returns the hour in the date.
Example: Ibid.
date to minute function : minute
Syntax: Minute (string date)
return value: int
Description: Returns the minute of the date.
Example: Ibid.
date to seconds function : Second
Syntax: Second (string date)
return value: int
Description: Returns the seconds in the date.
Example: Ibid.
Date-to- week function : weekofyear
Syntax: WeekOfYear (string date)
return value: int
Description: Returns the number of days in the current week.
Example:
Hive>Select weekofyear ('2016-02-16' from Dual;ok 70.2131 row (s)
Date comparison function : DateDiff
syntax: DateDiff (string EndDate, String startdate)
return value: int
Span style= "font-family: Song body; font-size:12px; " > Description: Returns the number of days from the end date minus the start date.
example:
Hive>Selectdatediff('2015-12-20',' 2016-02-15' from dual;ok-0.34 1 Row (s)
Date increment function : date_add
syntax: Date_add (string StartDate, int days)
return value: string
example:
hive> select Date_add ( ' 2015-12-08 ' ,
date reduction function : Date_ Sub Syntax: date_sub (string startdate, int days)
return value: String
example:
Hive>Select date_sub ('2015-12-08',ten from Dual;ok-0.249 1 Row (s)
Hive Function Summary-date function