HP 3000 Manuals

DATE Command [ HP ALLBASE/4GL Developer Reference Manual Vol. 2 ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Reference Manual Vol. 2

DATE Command 

The DATE command performs various calculations on dates.

The DATE command exists in four formats as shown below.  The first format
calculates the difference in days between two given dates.  The second
and third formats calculate the date obtained by adding or subtracting a
number of days to a given date.  The fourth format calculates the day of
the week corresponding to a given date.

Formats 

DATE date_field_1 *DIFF date_field_2 = no_days 

DATE date_field_1 {+ days} = result_date [;command]
                  {- days}

DATE date_field_1 *DAY = day_field 

Parameters 

date_field 

A field containing a valid date.  It can be any of the following:

   *   Date in quotes in the form "YY/MM/DD", where YY is the year, MM is
       the month, and DD is the day.

   *   Variable or calculated item.

   *   Alphanumeric constant.

   *   Screen field reference.

   *   Scratch-pad field reference.

   *   File record field reference.

   *   Work area field reference.

   *   *DATE.

If this field doesn't contain a valid date, HP ALLBASE/4GL displays an
error message and processing then continues.

no_days 

The first format of the DATE command calculates the difference in days
between two dates and places the result in the field no_days.  This field
can be any of the following:

   *   Variable.

   *   Screen field reference.

   *   Scratch-pad field reference.

   *   File record field reference.

   *   Work area field reference.

   *   Numeric communication area field.

days 

The second and third formats for the DATE command calculate a date by
adding or subtracting a number of days in the field days from the date in
the field date-field.  The field days can be one of the following:

   *   Whole number.

   *   Numeric constant.

   *   Variable or calculated item.

   *   Screen field reference.

   *   Scratch-pad field reference.

   *   File record field reference.

   *   Work area field reference.

   *   Numeric communication area field.

result_date 

The field where the result date calculated in the second and third
formats of the DATE command is placed.  This field can be any of the
following:

   *   Variable with edit code D.

   *   Screen field reference.

   *   Scratch-pad field reference.

   *   File record field reference.

   *   Work area field reference.

command 

An optional command executed if the century of the date represented by
the value in result_date differs from the century of the date in
date_field.  The command can be one of the following:

   *   ENTER

   *   EXIT

   *   EXTERNAL

   *   MESSAGE

   *   PROCEED

   *   SERIES

   *   TOP

   *   VISIT

   *   ZIP

If you don't specify an optional command and a century overflow error
occurs, the application aborts.

day_field 

The fourth format of the DATE command calculates the day of the week
corresponding to the date in date_field.  This form of the command
returns a single digit between 1 and 7, representing the days from Sunday
through to Saturday respectively.  The day_field can be any of the
following:

   *   Variable.

   *   Screen field reference.

   *   Scratch-pad field reference.

   *   File record field reference.

   *   Work area field reference.

   *   Numeric communication area field.

Example 1 

     DATE *DATE *DIFF * = V- days_elapsed}

This command compares the current date with the date in the current
screen field.  The command writes the difference between the two dates
into the variable days_elapsed.

Example 2 

     DATE V-Due_date *DAY = *P01

This command determines the day of the week corresponding to the date in
the variable Due_date.  The command writes a single digit from 1 through
7 to scratch pad field number one.  The output number represents the day
of the week, with 1 representing Sunday and 7 representing Saturday.



MPE/iX 5.0 Documentation