Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig >> mail # user >> Need to get date from datetime.


Copy link to this message
-
Need to get date from datetime.
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
+
Steve Bernstein 2013-10-07, 20:44
+
Steve Bernstein 2013-10-07, 20:48
+
Krishnan Narayanan 2013-10-07, 20:54
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB