Page 1 of 1

Timestamp Formatting

Posted: Thu Feb 16, 2006 11:57 am
by slavik0329
Hey,

I have a timestamp column comming in from a source file as:

2006-02-01 00.00.00.000000

I need to have it come out as:

2006-02-01-00.00.00.000000

Currently my stage is doing a seq to seq. How do I format the timestamp properly?

Thanks,
Steve

Posted: Thu Feb 16, 2006 12:02 pm
by sjhouse
In your transformer, you can set up the derivation using either a group extract or the field function and concatonate the items.

DT_FLD[1,10] : "-" : DT_FLD[12,15]

This should give you your desired value.

Stephen

Posted: Thu Feb 16, 2006 12:23 pm
by I_Server_Whale
Hi Steve,

You can also accomplish it by using the Ereplace function.

Ereplace (string, substring, replacement [ ,number [ ,begin] ] )

string is the string or expression.

substring is the substring you want to replace. If substring is an empty string, the value of string is returned.

replacement is the replacement substring. If replacement is an empty string, all occurrences of substring are removed.

number specifies the number of instances of substring to replace. To change all instances, use a value less than 1.

start
specifies the first instance to replace. A value less than 1 defaults to 1.


you can code your derivation this way:

Code: Select all



DT_FLD = Ereplace(Trim(InLink.DT_FLD, " ", "-") 

Thanks,
Naveen.

Posted: Thu Feb 16, 2006 12:26 pm
by I_Server_Whale
Oops! Sorry.

I missed a parethesis in the code. It should be

Code: Select all


DT_FLD = Ereplace(Trim(InLink.DT_FLD), " ", "-") 

Let me know if it worked.

Thanks,
Naveen.

Posted: Thu Feb 16, 2006 2:24 pm
by slavik0329
naveendronavalli wrote:Oops! Sorry.

I missed a parethesis in the code. It should be

Code: Select all


DT_FLD = Ereplace(Trim(InLink.DT_FLD), " ", "-") 

Let me know if it worked.

Thanks,
Naveen.

Thanks alot Naveen. Works great! :D