DATE Function

The DATE function returns the current date in internal format.

Format

DATE( )

Description

The DATE function returns the numeric value of the internal system date. The internal format for the date is the number of days since December 31, 1967, which is considered day 0. All dates after December 31, 1967, are positive numbers representing the number of days that have elapsed since then. All dates prior to day 0 are negative numbers representing the number of days prior to this date.

Data calculations are generally much easier when dates are stored in internal format. For example, 90 days from -940 is easier to calculate than 90 days from June 4, 1965. To convert an internal date to external (human-readable) format, the OCONV function may be used with the D specification. Similarly, the ICONV function may be used to convert from external to internal format.

The TIME function returns the current time in internal format, and the TIMEDATE function returns the current time and date in external format. See TIME Function and TIMEDATE Function for more information.

Example

In this application the last billing date for each customer is stored in Attribute 8 of the file item, in internal format. Thirty days are given for the bill to be paid. The DATE function is used to capture the current date and compare it against the last billing date, to determine if the bill is overdue.

PRINT "ENTER THE CUSTOMER ID : " :

INPUT ID

READV BILLING.DATE FROM CUSTFILE , ID , 8 ELSE         

   PRINT "CANNOT READ!"

   STOP

END

TODAY = DATE ( )

PAY.DATE = BILLING.DATE + 30

PAY.DATE.EXT = OCONV(PAY.DATE, "D")

BEGIN CASE

CASE TODAY < PAY.DATE

   PRINT "YOUR NEXT BILL IS DUE " : PAY.DATE.EXT

: "."

CASE TODAY = PAY.DATE

   PRINT "YOUR BILL IS DUE TODAY."

CASE TODAY > PAY.DATE

   PRINT "YOUR BILL WAS DUE " : PAY.DATE.EXT : "."     

   PRINT "YOU ARE " : TODAY-PAY.DATE : " DAYS

OVERDUE."

END CASE

See Also

Statement and Function Reference