Navigation:  Programs > Command-Line Utilities >

RUNDATE

Previous pageReturn to chapter overviewNext page

Command Expansion Utility

RUNDATE [[+|-]n[h|d|m|n]] command


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 CATDBF 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 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)
%m month (01-12)
%M minute (00-59)
%p am/pm indicator for locale
%S second (00-59)
%w weekday (0-6, Sunday is 0)
%W week number in year (00-53) (week starts on Monday)
%x date for locale
%X time for locale
%y year without century
%Y year with century
%z time zone abbreviation
%% percent sign

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.

Command-Line Arguments:

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.

Examples:

Assume that the program is being run on Tuesday September 2nd, 2003 and that all command examples are run from within batch files.

Expand current date:

RUNDATE "RADATA2 %%y%%m%%d"

(runs: RADATA2 030902)

Expand date two days ago:

RUNDATE -2d "RADATA2 %%y%%m%%d"

(runs: RADATA2 030831)

Expand last month's date:

RUNDATE -1m "CATDBF MONTH%%m %%Y%%m??.dbf"

(runs: CATDBF MONTH08 200308??.DBF)

Display comment:

RUNDATE -1m "echo Making file for %%B %%Y"

(prints: Making file for August 2003)

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)

 


Topic url: http://www.copia.com/support/refmanual/index.html?rundate.htm