Is there a way where I can get today's date in Pig Script in yyyy-mm-dd format. I am unable to get hold of any API for that.
Thanks
You can define a TODAYS_DATE
variable like this:
%default TODAYS_DATE `date +%Y-%m-%d`;
and refer to it every time you need by inserting $TODAYS_DATE
in the string:
'/data/mydata/$TODAYS_DATE'
Make sure to make no typing mistakes. You may also use %declare
, but you will lose the flexibility to override the value from the command line or parameter file.
You can use ToString(CurrentTime(),'yyyy-MM-dd') as date:chararray
in your pig script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With