[Solved-2 Solutions] Formatting Date in Generate Statement of pig ?
In Pig, if you have a statement which basically appends the date to generated values.
The output gives me the date
2013-05-25T09:01:38.914-04:00 in ISO8601.
How to make this just as "YYYY-MM-DD" ?
- We have several options:Convert it with Pig functions :
- OR pass the date to the script as a parameter:
- OR declare it in script:
- Then refer to the variable as '$CURR_DATE' in the script.
- We may also create a modified CurrentTime UDF in which we convert the DateTime object to the appropriate format with the Joda-Time library.
- If we are using Pig 0.12 .
- We can use ToString(CurrentTime(),'yyyy-MM-dd')
- we can use any datetime type instead of CurrentTime()