system date in RPG
0 pts.
0
Q:
system date in RPG
RPG
We have a dataq job that runs constantly. There are trigger programs on some files that control what is sent to the dataq which in turn prints certain forms at the correct outq. is there a 'date' variable that will reflect NOW? Udate and *date gives the same thing - the job start date. i realize i can retrieve system value, but wondered if that was the only solution. thanks.
ASKED: Jul 20 2005  11:21 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
7560 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Assuming you're using RPG, use the TIME opcode to get the current date and/or time. You are correct in that UDATE gives the session date, and not the system date.
Rick

========================================================

A date field can be initialized to the current system date. This is not the same as the "job date" that is available through UDATE or *DATE. The INZ(*SYS) initialization brings system date into the variable. Example:

h dftactgrp( *NO )
h actgrp( *CALLER )
h debug

d curDate s d inz( *sys )
d ctr s 5i 0 inz( 0 )

/free

curDate = d'2009-10-01' ;

for ctr = 1 to 16 by 5 ;
reset curDate ;
curDate += %days( ctr ) ;
endfor ;

eval *inlr = *on ;
return ;

/end-free

Run that example in debug to watch how curDate changes. It initializes to system date when the program starts. The first executeable statement sets curDate to '2009-10-01'. In the FOR-loop, the RESET operation sets curDate to its initialization value -- the system date again.

The curDate is incremented by a duration based on the loop counter which counts by five. Each time through, curDate is reinitialized before being incremented by larger and larger values.

RESET is one simple way to set date fields to system date.

Tom
Last Answered: Oct 30 2009  5:29 AM GMT by TomLiotta   7560 pts.
Latest Contributors: RickMe   15 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

WaltZ400   535 pts.  |   Jul 20 2005  12:52PM GMT

If you are using ILE RPG, in D-specs define a date variable in whatever date format you use and add keyword INZ(*SYS) to it. When the program starts this variable is set to the system date. Likewise if you want job date, do a INZ(*JOB) on a date variable.

 

WilsonAlano   2005 pts.  |   Oct 30 2009  2:35PM GMT

Hi,

You can do

Eval Date = %Date()

It will returns the current date which IMHO is a little more readable than the Reset technique.

Wilson

 
0