Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the date functions of hive

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail what the hive date function has, and the editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

1. Date function to_date (string expr)

Return type: string

Description: returns the time string date section

To_date (expr)-Extracts the date part of the date or datetime expression expr

Example:

Hive > select to_date ('2014-09-16 1515 from default.dual 08.119')

2014-09-16

two。 Year function year (string expr)

Return type: int

Description: returns time string, year number

Year (date)-Returns the year of date

Example:

Hive > select year ('2014-09-16 1515 from default.dual 08.119')

2014

3. Month function month (string expr)

Return type: int

Description: returns time string month number

Month (date)-Returns the month of date

Example:

Hive > select month ('2014-09-16 1515 from default.dual 08.119')

09

4. Celestial function day (string expr)

Return type: int

Description: returns the day of the time string

Day (date)-Returns the date of the month of date

Example:

Hive > select day ('2014-09-16 1515 from default.dual 08.119')

sixteen

5. Hour function hour (string expr)

Return type: int

Description: returns time string hour number

Hour (date)-Returns the hour of date

Example:

Hive > select hour ('2014-09-16 1515 from default.dual 08.119')

fifteen

6. Minute function hour (string expr)

Return type: int

Description: returns the time string, minute number

Minute (date)-Returns the minute of date

Example:

Hive > select minute ('2014-09-16 1515 from default.dual 08.119')

fifty

7. Second function second (string expr)

Return type: int

Description: returns the time string, minute number

Second (date)-Returns the second of date

Example:

Hive > select second ('2014-09-16 1515 from default.dual 08.119')

08

8. Date increment function date_add (start_date, num_days)

Return type: string

Description: returns the date when the number of num_days days is increased (a negative number is a decrease)

Date_add (start_date, num_days)-Returns the date that is num_days after start_date.

Example:

Hive > select date_add ('2014-09-16 15 from default.dual 50V 08.119) from default.dual

2014-09-26

Hive > select date_add ('2014-09-16 15-15-15-50-8. 119) from default.dual

2014-09-06

9. Date reduction function date_sub (start_date, num_days)

Return type: string

Description: returns the date before the number of num_days days (a negative number is an increase)

Date_sub (start_date, num_days)-Returns the date that is num_days before start_date.

Example:

Hive > select date_sub ('2014-09-16 15 from default.dual 50V 08.119) from default.dual

2014-09-06

Hive > select date_sub ('2014-09-16 15-15-15-50-8. 119) from default.dual

2014-09-26

10. Periodic function weekofyear (start_date, num_days)

Return type: int

Description: returns the cycle with the current date in this year, one cycle a week.

Weekofyear (date)-Returns the weekof the year of the given date. A week is considered to start on a Monday and week 1 is the first week with > 3 days.

Example:

Hive > select weekofyear ('2014-09-16 1515 from default.dual 08.119')

thirty-eight

11. Date comparison function weekofyear (start_date, num_days)

Return type: string

Description: returns the date difference between 2 times

Datediff (date1, date2)-Returns the number of days between date1 and date2

Date1-date2

Example:

Hive > select datediff ('2014-09-16 1515 from default.dual 08.119) from default.dual

This is the end of this article on "what are the hive date functions?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report