I am trying to convert the way time is written in the flat file source so it would actually look like time.(If that makes any sense).
Right now I have it as 1215
, 630
, 10
, 1
,.. etc. So it can be 4-1 character long, so I need to convert it depending on the length of the column.
I am doing this in Derived Column with an expression, however I can't seem to make it work, not sure if my syntax is wrong or what, the expression looks like this, however I'm getting errors:
(LEN([TIME OCC]) == 4) ? (SUBSTRING([TIME OCC],1,2) + ":" + SUBSTRING([TIME OCC],3,2)) : (LEN([TIME OCC]) == 3) ? (SUBSTRING([TIME OCC],1,1) + ":" + SUBSTRING([TIME OCC],2,2)) : (LEN([TIME OCC]) == 2) ? (SUBSTRING([TIME OCC],1,2) + ":00") : (LEN([TIME OCC]) == 1) ? (SUBSTRING([TIME OCC],1,1) + ":00")
When I do it with only two values like below it seems to work perfectly:
LEN([TIME OCC]) == 3 ? SUBSTRING([TIME OCC],1,1) + ":" + SUBSTRING([TIME OCC],2,2) : SUBSTRING([TIME OCC],1,2) + ":" + SUBSTRING([TIME OCC],3,2)
I would appreciate any help, thank you!