Hi Marcel and Denver

i need additinal the time in milliseconds
like
date 10.05.04.
time 19:25:30

=100504192530

Just a note: those are seconds not milliseconds.

$ZTS has milliseconds, but it is offset by $ZTZ minutes from local time.
Although, for a unique ID, especially in chronological order, $ZTS is much better,
particularly if your application is already deployed where there is fast time in the summer or where servers could be in different time zones.
That $ZTS is offset by $ZTZ doesn't hurt a thing since it's just a number to your application.


 S x=$zts
 Q $ZSTRIP($ZDT(x,3),"*P")_$E($P(x,".",2)+100,2,3)

If you really need both milliseconds and a true unique and sequential time but only a two digit resolution, you should not shift the milliseconds by 100 but round them to tens of milliseconds:


        W $ZTIME($PIECE($ZTIMESTAMP,",",2),1,2)
        14:34:23.56

Then - as I learned from Warlin today and your code example - you can apply $ZSTRIP and "*P" to this and concatenate it with $ZDATE with option 8 to obtain a clean numeric string:

        S x=$zts
        Q $ZDATE($P(x,",",1),8)_$ZSTRIP($ZTIME($P(x,",",2),1,2),"*P")
        2004032614342356

If you need resolution to the millisecond, just expand resolution from two to three digits:

        Q $ZDATE($P(x,",",1),8)_$ZSTRIP($ZTIME($P(x,",",2),1,3),"*P")
        20040326143423564

/gustav



Reply via email to