NEXT_DAY Function in Apache Hive & Impala

During data processing or data transformation, we often look for a suitable function to perform a particular task. If we can’t find a solution, we either build our own function or attempt to find a work-around. But, in Apache Impala there are several functions that aid in every area of data analysis. Next Day is one of the function that can deter us from worrying about a workaround.

Syntax:
NEXT_DAY(TIMESTAMP date, STRING weekday)
NEXT_DAY(Date, STRING weekday)

The first one returns the output in date and time format of the weekday that follows the specified date. The second one returns the output in date without timestamp.

The weekday parameter is case-insensitive. The following values are accepted for weekday: “Sunday”/”Sun”, “Monday”/”Mon”, “Tuesday”/”Tue”, “Wednesday”/”Wed”, “Thursday”/”Thu”, “Friday”/”Fri”, “Saturday”/”Sat”

Examples:
SELECT NEXT_DAY(‘2021-01-07′,’Saturday’);
— Returns ‘2021-01-09 00:00:00’ the first Saturday after 7th January 2021.

SELECT NEXT_DAY(NOW(), ‘Thu’);
The function returns ‘2021-01-14 00:00:00’, one week after the current date.

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

5 comments

  1. Hi there i am kavin, its my first time to commenting anyplace, when i read this piece of writing i thought i could also
    create comment due to this sensible paragraph.

    Like

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s