User Variable Activity syntax for timestamp
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 4
- Joined: Thu Jul 05, 2018 5:57 pm
User Variable Activity syntax for timestamp
Hi, i need to create current timestamp in (YYYY-MM-DD HH:MM:SS.ssssss) in User Variable Activity. Can anyone tell me the proper syntax to create a current timestamp in required format?
Well, at least one of the two questions were answered.
Have you done any BASIC programming of routines or job control code yet? Any experience with the System Variables? @DATE comes to mind but AFAIK it won't handle the milliseconds that you say you need. One would typically pair that with OConv() to convert it to an external format. You may need to leverage a call to your O/S to get a timestamp with milliseconds, what flavor of UNIX do you have and are there any functions available there you could use?
I'm sure others will chime in with thoughts but those are the first things that come to mind.
Have you done any BASIC programming of routines or job control code yet? Any experience with the System Variables? @DATE comes to mind but AFAIK it won't handle the milliseconds that you say you need. One would typically pair that with OConv() to convert it to an external format. You may need to leverage a call to your O/S to get a timestamp with milliseconds, what flavor of UNIX do you have and are there any functions available there you could use?
I'm sure others will chime in with thoughts but those are the first things that come to mind.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
And just in case you haven't seen this yet, here's a starting point in the online help for the stage.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Microseconds are not available in the function set available to user variable expressions.
I would suggest using an Execute Command activity, to execute the UNIX date command with appropriate arguments. For example (AIX):Pipe the result through tr if you need to change the "T" to a space. Pipe the result through cut if you don't need all of the fractional second digits.
I would suggest using an Execute Command activity, to execute the UNIX date command with appropriate arguments. For example (AIX):
Code: Select all
date +%Y-%m-%dT%H:%M:%S.%s
Last edited by ray.wurlod on Thu Jul 12, 2018 1:23 pm, edited 2 times in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
On AIX, if you want a space in the middle, then use double quotes:
Watch out for the %s option though as that is not fractional seconds, rather it is the number of seconds since 1/1/1970. I do not think the AIX date command has an option for fractional seconds. Searching suggests to write a little perl or C program to provide the resolution you need. That really seems like overkill to me!
As Craig had asked before, what version of Linux/UNIX is being used?
Also, can you just use zeros for the fractional second portion?
Code: Select all
date "+%Y-%m-%d %H:%M:%S"
As Craig had asked before, what version of Linux/UNIX is being used?
Also, can you just use zeros for the fractional second portion?
Choose a job you love, and you will never have to work a day in your life. - Confucius