We addressed in the previous post that “Date” is the most significant column that helps to explain patterns, trends and even business. From diagnostic analysis to prescriptive analysis and from descriptive analysis to prescriptive analysis, “Date/Time” plays a vital role.
We will need to equate the data for the present date with the data for the historical date. Or we may need to estimate the business on the basis of data from the historic date. Date functions help in such scenarios.
This article aims to let you know how to add and substract months to date column in Apache Hive.
- Note: The below specified function is common in both Apache Hive & Apache Impala.
This function returns the date after adding or substracting the number of months provided for a given date.
Example: (Click here for the sample dataset)
SELECT ADD_MONTHS(date1, 3) FROM DateTest;
SELECT ADD_MONTHS(date2,-3) FROM DateTest;
Hope you liked this post.
Please click on the follow button to receive updates on latest posts.