pig tutorial - apache pig tutorial - Apache Pig - WeeksBetween() - pig latin - apache pig - pig hadoop
What is WeekBetween() Function?
- WeeksBetween returns the number of whole weeks between ANow and AThen.
- This means the fractional part of a Week is dropped.
Learn apache pig - apache pig tutorial - Apache Pig Weeks Between - apache pig examples - apache pig programs
WeeksBetween() function in Apache Pig
- This function accepts two date-time objects and calculates the number of weeks 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, date of-birth and date-of-joining.
- We have loaded this file into Pig with a relation named doj_dob_data as given below.
- Now you can calculate the number of weeks between date-of-birth and date-of-joining of the employees using the WeeksBetween() function as given below.
- Verify the contents of the relation using the Dump operator as given below.
- The given statement stores the result in the relation named weeksbetween_data.