1.unix Timestamp to TIME function
|
syntax: From_unixtime (bigintunixtime[, string format]) return value: String Description: Conversion unix timestamp (from 1970-01-01 00:00:00 UTC to the number of seconds in the specified time) example of time format to the current time zone : Hive >selectfrom_unixtime (1323308943, ' yyyyMMdd ') fromdual; 20111208 |
2. Get the Unix timestamp for the current time zone?
12345678910 |
Syntax: Unix_timestamp () return value: bigint Description: An example of a Unix timestamp for the current time zone: Hive>selectunix_timestamp () fromdual; 1323309615 |
3. Time-to-unix timestamp?
1234567891011 |
Date to UNIX timestamp function: Unix_timestamp syntax: Unix_timestamp (stringdate) return value: bigint Description: Convert the date in the format "Yyyy-mm-dd HH:mm:ss" to the Unix timestamp. If the conversion fails, 0 is returned. Example: hive> selectunix_timestamp (' 2011-12-07 13:01:03′) fromdual; 1323234063 |
?
1234567891011 |
Specify format date to UNIX timestamp function: Unix_timestamp syntax: Unix_timestamp (stringdate, string pattern) return value: bigint Description: Converts the date in pattern format to the Unix timestamp. If the conversion fails, 0 is returned. Example: hive> selectunix_timestamp (' 20111207 13:01:03′, ' yyyyMMdd HH:mm:ss ') fromdual; 1323234063 |
4. Date time to date function?
12345678910 |
Syntax: To_date (Stringtimestamp) return value: String Description: Returns the date part in a DateTime field. Example: Hive>selectto_date (' 2011-12-08 10:03:01′) fromdual; 2011-12-08 |
5. Get the function of the year?
1234567891011121314 |
Syntax: Year (stringdate) return value: Int Description: Returns years in the date. Example: Hive>selectyear (' 2011-12-08 10:03:01′) fromdual; Hive>selectyear (' 2012-12-08′) fromdual; 2012 |
6. Get the Month function?
1234567891011121314 |
Syntax: month (stringdate) return value: Int Description: Returns the month of the date. Example: Hive>selectmonth (' 2011-12-08 10:03:01′) fromdual; Hive>selectmonth (' 2011-08-08′) fromdual; 8 |
7. Get the function of the day?
1234567891011121314 |
Syntax: Day (stringdate) return value: Int description: Returns days in a date. Example: Hive>selectday (' 2011-12-08 10:03:01′) fromdual; 8 Hive>selectday (' 2011-12-24′) fromdual; 24 |
8. Get the function of the hour?
12345678910 |
Syntax: Hour (stringdate) return value: Int Description: Returns the hour in the date. Example: Hive>selecthour (' 2011-12-08 10:03:01′) fromdual; 10 |
9. What is the function of getting fractions?
12345678910 |
Syntax: Minute (stringdate) return value: Int Description: Returns the minute of the date. Example: Hive>selectminute (' 2011-12-08 10:03:01′) fromdual; 3 |
10. Get the function of the second?
12345678910 |
Syntax: Second (stringdate) return value: Int Description: Returns the second of the date. Example: Hive>selectsecond (' 2011-12-08 10:03:01′) fromdual; 1 |
11. Gets the date in the current number of weeks?
12345678910 |
Syntax: WeekOfYear (stringdate) return value: Int Description: Returns the number of days in the current week. Example: Hive>selectweekofyear (' 2011-12-08 10:03:01′) fromdual; 49 |
12. Date comparison function?
12345678910 |
Syntax: DateDiff (String enddate, String startdate) return value: Int Description: Returns the number of days from the end date minus the start date. Example: Hive>selectdatediff (' 2012-12-08′, ' 2012-05-09′ ') fromdual; 213 |
13. Date Increment function?
12345678910 |
Syntax: Date_add (String startdate,intdays) return value: String Description: Returns the date that the start date startdate increased days. Example: Hive>selectdate_add (' 2012-12-08′,10) fromdual; 2012-12-18 |
14. Date reduction function?
12345678910 |
Syntax: Date_sub (String startdate,intdays) return value: String Description: Returns the date that the start date startdate reduced by days. Example: Hive>selectdate_sub (' 2012-12-08′,10) fromdual; |
Date conversion functions in hive