Command Expansion Utility
The RUNDATE program runs a console command with expansion of date or time values contained in the command string. It is provided to allow the automated processing of the CopiaFacts utilities such as CATDBFX which need a date in the command.
The parameter expansion is controlled by "%" symbols in the command string. The principal codes for use with dates are:
|%d||expands to day of month (01 - 31)|
|%m||expands to month number (01 - 12)|
|%y||expands to year (without century) (00 - 99)|
|%w||expands to day of the week (Sunday is 0)|
There are many other codes available, as documented for the ANSI standard C run-time function strftime(). The full list of available codes is as follows:
|%a||abbreviated weekday name|
|%A||full weekday name|
|%b||abbreviated month name|
|%B||full month name|
|%c||'short' date and time representation for locale|
|%d||day of the month (01-31)|
|%H||hour in 24-hour format (00-23)|
|%I||hour in 12-hour format (01-12)|
|%j||day of year (001-366)|
|%p||am/pm indicator for locale|
|%w||weekday (0-6, Sunday is 0)|
|%W||week number in year (00-53) (week starts on Monday)|
|%x||'short' date for locale|
|%X||time for locale|
|%y||year without century|
|%Y||year with century|
|%z||time zone abbreviation|
The date expanded is normally the current date, but to facilitate processing after a month has ended, RUNDATE has an optional parameter which will set the hour, month or day forward or back before performing the expansion. The examples below will make this clear.
|n||the number of minutes (n) hours, days or months (m) to adjust from the current date/time before expansion. The command should always be enclosed in quotes. You can add or subtract up to 24 hours, 12 months or 65 days. The plus or minus sign is required if the optional adjustment parameter is included. If the n, h, d and m are omitted, d is assumed.|
|command||the command to be executed (in double quotes)|
If you include the RUNDATE command in a batch file, the normal batch file syntax rules require that you duplicate the "%" signs as "%%".
If you refer to the ANSI specifications of strftime(), note that the locale for RUNDATE is fixed as the USA. Thus full-date expansions will always come out as MM/DD/YY, whatever you have set as the country code. An exception is that %z expands to the current timezone of the machine.
Assume that the program is being run on Wednesday September 2nd, 2015 and that all command examples are run from within batch files.
Expand current date:
RUNDATE "RADATA2 %%y%%m%%d"
(runs: RADATA2 150902)
Expand date two days ago:
RUNDATE -2d "RADATA2 %%y%%m%%d"
(runs: RADATA2 150831)
Expand last month's date:
RUNDATE -1m "CATDBFX %%Y%%m"
(runs: CATDBFX 201508)
RUNDATE -1m "echo Making file for %%B %%Y"
(prints: Making file for August 2015)
Move yesterday's CopiaFacts error trace file to an archive
RUNDATE -1d "PKZIP -m KEEPTRC M1.TR%%w"
(moves M1.TR5 to the ZIP file)