pig tutorial - apache pig tutorial - Apache Pig - HoursBetween() - pig latin - apache pig - pig hadoop
What is HoursBetween() function in Apache Pig ?
- HoursBetween returns the number of hours between two DateTime objects
- This function accepts two date-time objects and calculates the number of hours between the two given date-time objects.
Learn apache pig - apache pig tutorial - hours between in apache pig - apache pig examples - apache pig programs
Syntax
Example
- Ensure that we have a file named wikitechy_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, date-of-birth, and date-of-joining.
wikitechy_doj_dob.txt
We have loaded this file into Pig with a relation named doj_dob_data as given below.
- Now you can calculate the number of hours between date-of-birth and date-of-joining of the employees using the HoursBetween() function as given below.
Verification
- Verify the contents of the relation using the Dump operator as given below.
Output
- The above statement stores the result in the relation named hoursbetween_data.