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.
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 )
d curDate s d inz( *sys )
d ctr s 5i 0 inz( 0 )
curDate = d’2009-10-01′ ;
for ctr = 1 to 16 by 5 ;
reset curDate ;
curDate += %days( ctr ) ;
eval *inlr = *on ;
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.