Page 1 of 1

How to get timestamp with microsecond

Posted: Thu Aug 26, 2010 4:01 am
by hailun
Hi,

In project,we need get time-stamp and what we are doing is achieving this via CurrentTimestamp() function in D/S transformer stage but we can only get a value timed to second such as '2004-03-02 16:28:26', and now we wanna one value timed to microsecond such as '2010-08-05 13:29:09.970000',is there any way.

BTW,current datastage version is 7.5.1:
uv -admin -version
DataStage 7.5.1.2

Appreciating your input in advance,

Thanks,

Posted: Thu Aug 26, 2010 5:37 am
by chulett
What operating system? An exact search for "microsecond" should turn up other conversations on this topic, including (from what I recall) the operating systems where this does or does not work.

Posted: Thu Aug 26, 2010 6:23 am
by mhester
Try CurrentTimestampMS() and set the extended properties of the column to include micro seconds and set length to 26 and scale to 6.

CurrentTimestamp() will give just seconds as you presented if the extended properties are not set. If they are you would get 000000 as the micro seconds.

Using CurrentTimestampMS() should solve your issue.

Posted: Thu Aug 26, 2010 7:38 am
by hailun
chulett wrote:What operating system? An exact search for "microsecond" should turn up other conversations on this topic, including (from what I recall) the operating systems where this does or does not work.
Hi chulett,thanks a lot for reply, OS is AIX 5.1,I seached the forum,but unble to get the answer :(

Posted: Thu Aug 26, 2010 7:39 am
by hailun
mhester wrote:Try CurrentTimestampMS() and set the extended properties of the column to include micro seconds and set length to 26 and scale to 6.

CurrentTimestamp() will give just seconds as you presented if the extended properties are not set. If they are you would get 000000 as the micro seconds.

Using CurrentTimestampMS() should solve your issue.
Hi mhester,many thanks for reply,I tried you method but I'm unabe to see fucntion CurrentTimestamp() in the transfermor stage,,seems 7.X D/S has no function CurrentTimestampMS() :(

Posted: Thu Aug 26, 2010 7:58 am
by chulett
You may need to upgrade or roll you own. Also, Mike has already mentioned this but so has Arnd in the past:
ArndW wrote:You will need to declare your Timestamp column with the extended attribute of "microseconds" in order to store fraction seconds.
Have you enabled that attribute?

Posted: Thu Aug 26, 2010 8:29 am
by mhester
Here you go - something to get you started with your own -

Code: Select all

char *pfGetTimestamp()
{

    char* returnBuffer;

    TimeStampStringValue = APT_TimeStamp::now(true).asString();

    returnBuffer = TimeStampStringValue.content();

    return  returnBuffer;

}