Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

How to substractduration of 1min from a ISO time in Pig ?

avatar
Rising Star
 
1 ACCEPTED SOLUTION

avatar
Expert Contributor
all the comments mentioned here are correct,this is small example


emp = load 'data' using PigStorage(',') as (empno,ename ,job,mgr,hiredate ,sal,comm,deptno);
each_date = foreach emp generate ToDate(hiredate,'dd-MMM-yyyy') as mydate;
subt = foreach each_date generate mydate,SubtractDuration(mydate,'PT1M');
dump subt;

View solution in original post

4 REPLIES 4

avatar
Master Mentor

avatar
Master Mentor
@Pradeep Allu

you need to refer to the standard for ISO 8601 to specify duration or period linked Here. For example PT1M is a one-minute duration. Here's the implementation of the function if you need clear understanding. Get to know jodatime java library and Period object to get a handle on this function. Excellent question!

avatar
Expert Contributor
all the comments mentioned here are correct,this is small example


emp = load 'data' using PigStorage(',') as (empno,ename ,job,mgr,hiredate ,sal,comm,deptno);
each_date = foreach emp generate ToDate(hiredate,'dd-MMM-yyyy') as mydate;
subt = foreach each_date generate mydate,SubtractDuration(mydate,'PT1M');
dump subt;

avatar
Expert Contributor

use ISO time pattern instead of dd-MMM-yyyy from my code