Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Get Time from a String ''yyyy-MM-dd hh:ss:mm' field

Solved Go to solution
Highlighted

Get Time from a String ''yyyy-MM-dd hh:ss:mm' field

Hi experts,

I've the following field :

ToString( ToDate((long) Time_Interval), 'yyyy-MM-dd hh:ss:mm') as Time

How can I obtain only the time (hh:ss:mm)? I already try: ToString( ToDate(Time), 'HH:mm:ss.SSS')

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Get Time from a String ''yyyy-MM-dd hh:ss:mm' field

Super Guru

@Pedro Rodgers I would use the GetMinute, GetSecond, Get MilliSecond functions.

View solution in original post

3 REPLIES 3
Highlighted

Re: Get Time from a String ''yyyy-MM-dd hh:ss:mm' field

Super Guru

@Pedro Rodgers I would use the GetMinute, GetSecond, Get MilliSecond functions.

View solution in original post

Highlighted

Re: Get Time from a String ''yyyy-MM-dd hh:ss:mm' field

Sunile Manjee many thanks! One more question: is possible to create a variable and use to IF statement. Example: A = Foreach X Generate A1,A2,A3; --Create a variable var = Concat(A1,A2); Split A into B IF (var == "teste"); Is possible to do this?

Highlighted

Re: Get Time from a String ''yyyy-MM-dd hh:ss:mm' field

Super Guru

You have to use arithmetic operation like

X = FOREACH A GENERATE f2, (f2==1?1:COUNT(B));

Or embed pig in wrapper

http://pig.apache.org/docs/r0.11.0/cont.html#embed-python

Don't have an account?
Coming from Hortonworks? Activate your account here