Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig, mail # user - Need to get date from datetime.


Copy link to this message
-
Need to get date from datetime.
Krishnan Narayanan 2013-10-07, 20:02
Hi,

can some one help me getting date from date time.I need to find data
difference between two date.

(1,2013-09-25 13:01:20.1)
(2,2013-09-25 12:01:25.2)
(3,NULL)

a = load '/home/pig/sample.txt' using PigStorage(',') AS
(id:int,trial_dt:chararray);

DEFINE CustomFormatToISO
org.apache.pig.piggybank.evaluation.datetime.convert.CustomFormatToISO();

b = foreach a generate
CustomFormatToISO(SUBSTRING(trial_dt,1,19),'YYYY-MM-DD') as
Trail_dt:chararray;

dump b;

Error:

java.lang.Exception: java.lang.IllegalArgumentException: Invalid format:
"013-09-25 13:01:20" is malformed at " 13:01:20"
        at
org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:404)
Caused by: java.lang.IllegalArgumentException: Invalid format: "013-09-25
13:01:20" is malformed at " 13:01:20"
        at
org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:683)
Thanks
Krishnan