I am using [clock format [clock seconds] -format “%Y%M%d%H%M%S”] to retrieve current system date upto seconds.
The output for the above statement is “201009291510129”, but I would like to know if there is a similar way to retrieve upto milliseconds in the above format. Thanks
You can use “clock clicks” to get a time counter in milliseconds, but this value doesn’t seem to be synchronized with “clock seconds”. In other words, [expr [clock clicks -milliseconds]%1000] doesn’t go to zero at the time that [clock seconds] changes.
What I do is to use the clock seconds plus a 3 character literal plus a counter. The counter breaks ties at the seconds level, the literal means I can have uniqueness accross systems as well as within a system (across sytems can be useful if the receiving system is getting messages from multiple sources (ADT, Orders, Results, etc.) and every message has to have a unique ID forever.
The above mecahnism can assure such uniqueness and still stay within the 22 character limit of MSH-10.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
Well, if you’re mostly concerned with uniqueness, you could use something like
Code:
clock format [clock seconds] -format “%Y%M%d%H%M%S[expr [clock clicks -milliseconds]%1000]”
.
Just be aware that the milliseconds portion of the time will probably guarantee uniqueness, but won’t always be sequential. In other words, a message may come in the same second as another message, and it’s timestamp might have a lower value.
I don’t think that will assure uniqueness since the value gene4rated by the clock clicks -milliseconds will have the same value within a given second. So if multiple messages are delviered per second they will all have the same ID.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
clock clicks -milliseconds gives you a counter that changes each millisecond, so if you call it twice within a second (but not within a millisecond) it will be unique.
Author
Replies
Viewing 5 reply threads
The forum ‘Cloverleaf’ is closed to new topics and replies.