pig tutorial - apache pig tutorial - Apache Pig - MilliSecondsBetween(datetime1, datetime2) Function - pig latin - apache pig - pig hadoop
What is MilliSecondsBetween(datetime1,datetime2)Function in Apache Pig ?
- The MilliSecondsBetween(datetime1,datetime2) function accepts the two date-time objects and also calculates the number of milliseconds which is done between the two given date-time objects.
- The MillisSecondsBetween(datetime1,datetime2) functionreturn the number of whole millisecondsbetweendatetime 1anddatetime2.
- TheMilliSecondsBetween(datetime 1,datetime 2) will always returns a positive result and also the parameter values are interchangeable.
Syntax
Example
- Ensure that we have a file named wikitechy_doj_dob.txt in the HDFS directory /pig_data/.
- The file contains the date-of-birth details and date-of-joining details of a particular person, id, dateof-birth and date-of-joining.
wikitechy_doj_dob.txt
- We have loaded the file into Pig with a relation name called doj_dob_data which is given below:
- We will calculate the number of milli seconds which is given between date-of-birth and date-of-joining of all the employees by using the MilliSecondsBetween() function which is given below:
Verification
- We need to verify the contents of the relation by using the Dump operator as shown below.
Output:
- The above statement stores in the relation named millisecondsbetween_data