Timestamp Formatting

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
slavik0329
Participant
Posts: 11
Joined: Tue Jan 10, 2006 2:33 pm

Timestamp Formatting

Post 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
sjhouse
Premium Member
Premium Member
Posts: 43
Joined: Tue Nov 02, 2004 12:11 pm
Location: Minneapolis, MN

Post 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
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post 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.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post 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.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
slavik0329
Participant
Posts: 11
Joined: Tue Jan 10, 2006 2:33 pm

Post 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
Post Reply