Convert varchar to timestamp
Moderators: chulett, rschirm, roy
Convert varchar to timestamp
Have one more question again,
Have a job where input is SQL db and output is DB2 db. There appointment date is Varchar,12 in SQL db with the format of 201403021500 which I am trying to convert as 03/02/2014 3.00 PM (Timestamp)
Any help.
Thanks.
Have a job where input is SQL db and output is DB2 db. There appointment date is Varchar,12 in SQL db with the format of 201403021500 which I am trying to convert as 03/02/2014 3.00 PM (Timestamp)
Any help.
Thanks.
Classic problem - the format mask you use in the function needs to match the format of the incoming string, not any perceived output format. Timestamps don't have an internal format so it just needs to know how to parse the string to turn it into a timetamp.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
OK, hold on... is this a Server job as posted? If so, my bad, lost track of what forum we were in - that function is a Parallel function, which would be why it would not be "accepted". You'd either need to work with IConv/OConv or just substring it apart and put it back together in the format that you need.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Craig,
Thanks a lot. I thought so. We have all the way top to bottom OCON/INCONV floating... lol.
Now, I used the below substrings function, which transformer is not accepting. Anything wrong with the "" in transformer.
As input is 201302031500, and output is 03/02/2013 3.00Pm.I used,
SUBSTRINGS(input,1,4):''-'':SUBSTRINGS(input,5,2):''-'':SUBSTRING(input,7,2):'' '':SUBSTRINGS(input,9,2):'':'':SUBSTRINGS(input,11,2):'':00''
Any thought.
Thanks a lot. I thought so. We have all the way top to bottom OCON/INCONV floating... lol.
Now, I used the below substrings function, which transformer is not accepting. Anything wrong with the "" in transformer.
As input is 201302031500, and output is 03/02/2013 3.00Pm.I used,
SUBSTRINGS(input,1,4):''-'':SUBSTRINGS(input,5,2):''-'':SUBSTRING(input,7,2):'' '':SUBSTRINGS(input,9,2):'':'':SUBSTRINGS(input,11,2):'':00''
Any thought.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Except that the middle one needs to be SUBSTRINGS (I assume you made a typo here) that will work.
Another possbility - which I believe is better self-documented - is
Another possbility - which I believe is better self-documented - is
Code: Select all
Fmt(InLink.TheValue, "L####-##-## ##:##:00")
Last edited by ray.wurlod on Thu Apr 10, 2014 5:11 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.