Support Questions
Find answers, ask questions, and share your expertise

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

Solved Go to solution
Highlighted

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

Contributor
 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

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

Rising Star
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
Highlighted

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

Highlighted

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

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!

Highlighted

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

Rising Star
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

Highlighted

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

Rising Star

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