Adding and Substracting Days to a Date – Apache Hive & Impala

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 days to date column in Apache Hive.

  • Note: The below specified functions are common in both Apache Hive & Apache Impala.

Adds a number of days to given date.

Substracts a number of days to given date.

Examples: (Click here for sample data)

However, if you provide a negative value to Date_Add function, it will be equal to Date_Sub. Refer to the following example.


Hope you liked this post.

Please click on the follow button to receive updates on latest posts.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s