AS400 RPG – last three digits of microseconds always zero!

5,020 pts.
Tags:
AS/400
ILE RPG
RPG
Timestamp
We noticed in a couple of programs where we were using timestamps that the rightmost three positions are consistently zero and never otherwise. I have tested this with even just a simple ILE RPG program that dsplys a %char(%timestamp()); and still only get zeros for the last three digits. However...pulling a microsecond(current timestamp) in an interactive SQL session provides a value which has all six digits being used. So, is this a limitation of RPG? Is there something else I am missing? Is anyone else using microseconds at all in RPG that can vouch for this ever using the last three digits? Thanks in advance!!
ASKED: May 15, 2009  2:43 PM
UPDATED: January 9, 2011  4:56 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

It’s a RPGILE limitation and it’s always zero. Do you really need this 3 digits? I think you can get it with APIs or C functions.

Regards,
Wilson

——————————–

<pre>
C/exec sql
C+ set :test = current_timestamp
C/end-exec
</pre>
or in /FREE
<pre>
exec sql set :test = current_timestamp;
</pre>
will set the program field TEST equal to a full timestamp (e.g. ’2009-05-18-10.55.25.250256′)

Kevin C. “BigKat” Ketzler

//////////////////////////////////////////////////////
Hi,

I was looking and found gettimeofday() to get time and Qp0zCvtToMITime() to convert it to timestamp.

Regards,
Wilson

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Koohiisan
    Wilson, thanks for the verification of what we suspected. Yes, it would be nice to get the whole 6 because the timestamp is being used in an audit trail. We want to be able to look at the audit trail and sort it by the timestamp to see the exact sequence of events recorded. But, with the speed of the events that take place, nearly all of them happen within the exact same time according to the timestamp. I figured that the remaining three digits may make enough difference to help. I had not considered an API, but I'll see if I can dig up one that gets me the data. I'll post whatever I find here for the benefit of others.
    5,020 pointsBadges:
    report
  • Koohiisan
    I couldn't find an API, and no one installed the C compiler, so I just ended up just using embedded SQL to do: /exec sql select microsecond(current timestamp) into :tmpfield from sysibm/sysdummy1; I also created a small SQLRPGLE program that could be called by other programs to return this value. Hope this helps someone else who stumbles onto this limitation!
    5,020 pointsBadges:
    report
  • Koohiisan
    Great, BigKat! Thanks!! I knew there must've been a simpler way in SQL... ^_^
    5,020 pointsBadges:
    report
  • Koohiisan
    Wilson, Can I use Qp0zCvtToMITime in RPG w/o using C at all? If so, that would be cool. But, the only examples I saw just now for that API were in C. :( Thanks!
    5,020 pointsBadges:
    report
  • WilsonAlano
    Hi, Yes you can call this APIs from RPGILE and you just need to know haw to pass parameters to this APIs. Just take a look to this page : Regards, Wilson
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following