Apache Pig - date&time- HoursBetween() - Apache Pig

What is Apache Pig HoursBetween()?

This function accepts two date-time objects and calculates the number of hours between the two given date-time objects.

Syntax

Here is the syntax of the HoursBetween() function.

Example

Assume that there is a file named doj_dob.txt in the HDFS directory /pig_data/. This file contains the date-of-birth and date-of-joining details of a particular person, id, dateof-birth, and date-of-joining.
doj_dob.txt
And, we have loaded this file into Pig with a relation named doj_dob_data as shown below.
Let us now calculate the number of hours between date-of-birth and date-of-joining of the employees using the HoursBetween() function as shown below.
The above statement stores the result in the relation named hoursbetween_data. Verify the contents of the relation using the Dump operator as shown below.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Apache Pig Topics