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.

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

avatar
Rising Star

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

avatar
Master Guru

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

View solution in original post

3 REPLIES 3

avatar
Master Guru

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

avatar
Rising Star

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?

avatar
Master 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