Search code examples
datastage

Datastage String Conversion to Timestamp


I have been tasked with converting a string which can come in different formats like such(mm/dd/yyyy, m/dd/yyyy, or mm/d/yyyy). However, it needs to be converted into a Timestamp with the following format (yyyy-mm-dd-00.00.000000). I have tried multiple conversion techniques within the Transformer stage; however, I have been unsuccessful. Basically, I pull the data from a file and stage it into a file in the same format as the table. I then insert into the database using the second file.


Solution

  • The main issue I was running into was the fact that the format could be mm/dd/yyyy or m/d/yyyy. The solution to this was to add a ",s" to my StringToTimestamp function.

    StringtoTimestamp(Input,,"%(m,s)/%(d,s)/%yyyy %hh:%nn:%ss").