Accessing Part of the Date – Apache Impala

The most critical and significant column is always the date/time in the data. A date/time dimension provides all the information you need for a given date and enables data to be processed as easily and reliably as possible.

The date/time helps in understanding the patterns, trends and even business. It (Date/time) plays a critical role, from diagnostic analysis to prescriptive analysis, from descriptive analysis to prescriptive analysis.

The most frequently mentioned date-time characteristics are: seconds, minute, hour, day, week, month, quarter and year.

The DATE_PART function helps in returning specific date part from a date column. Refer to the below examples.

SELECT DATE_PART(‘year’,now()) as current_year;
Returns only the current year. 

SELECT DATE_PART(‘month’,now()) as current_year;

Returns only the current month.

SELECT DATE_PART(‘day’,now()) as current_year;

Returns only the current date.

SELECT DATE_PART(‘hour’,now()) as current_year;

Returns only the current hour.

SELECT DATE_PART(‘minute’,now()) as current_year;

Returns only the current minute.

SELECT DATE_PART(‘second’,now()) as current_year;

Returns only the current second.

SELECT DATE_PART(‘millisecond’,now()) as current_year;

Returns only the current millisecond.

I hope you found this post to be informative.

Please join our mailing list to receive more interesting information.

2 comments

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 )

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