Page 1 of 1
Handling time with variable length
Posted: Wed Oct 07, 2015 12:29 pm
by sharmabhavesh
Hi,
I have a time field which can either be hhmmss or hmmss. The hour field can be 1-2 digits without a '0' being prefixed. How can I convert such string to time. I used %(h,s)nnss but that didn't work.
Posted: Wed Oct 07, 2015 5:46 pm
by ray.wurlod
I assume that you actually have a string field, since time fields don't have a format (they are stored as binary numbers).
Simply prefix the string with a "0" character and use the rightmost six characters of the result, with "%hh%nn%ss" as the format string.
Posted: Fri Oct 09, 2015 5:52 am
by sharmabhavesh
Hi Rar, Thanks for the solution. But can this be handled by specifying a format string. Read at some Datastage documentation to use %(h,s) in the format string but didn't work in my case.
Posted: Fri Oct 09, 2015 7:31 am
by chulett
The "s" means it can have a leading space. If "1-2 digits without a leading 0" means "1 thru 12" you can just use %h I would think.