pig tutorial - apache pig tutorial - Apache Pig - DaysBetween() - pig latin - apache pig - pig hadoop
What is DaysBetween() Function?
- The DaysBetween function subtracts the FromDate from the ToDate, returning the number whole day difference.
- The time value of each date is taken account of - only whole 24 hour chunks are counted as whole days.
Learn apache pig - apache pig tutorial - days between in apache pig - apache pig examples - apache pig programs
DaysBetween() function in Apache Pig
- This function accepts two date-time objects and calculates the number of days between the two given date-time objects.
- 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, dateof-birth, and date-of-join as given below.
- We have loaded this file into Pig with a relation named doj_dob_data as given below.
- Now you can calculate the number of days between date-of-birth and date-of-join of the employees using the DaysBetween() function.
Verify the contents of the relation using the Dump operator as given below.
- The above statement stores the result in the relation named daysbetween_data.