[Solved-2 Solutions] How to manipulate and compare dates in Pig ?
How to manipulate and compare dates in Pig ?
Use of yearbetween()
- This function accepts two date-time objects and calculates the number of years between the two given date-time objects.
- The syntax of the YearsBetween() function.
- In Pig 0.11 we can convert the date2 field from chararray to datetime data type using the ToDate() function, and then get the difference between the CurrentTime() and date2 using YearsBetween() and filter according to it.
- In pig 11, there are many functions available for comparing dates.
- date1:datetime and filter has condition: date1 >= ToDate('1999-01-01')