Date

See Also: Declaring Variables, Variable Declaration Commands, Time and Date Functions, Struct, String Functions

Purpose

Declares one or more Date variables.

Syntax

To declare Date variables

Date {date-identifier} [… {date-identifier}]

Where

To declare array variables of type Date

Date{dimension-list} {identifier} […{identifier}]

Where

What It Does

The Date command creates variables that contain date values.

Multiple variables may be declared on one command line, with their names separated from each other by spaces.

Date Arithmetic

Date arithmetic works according to the following table:

Operation

Result

Date + Integer

Date

Integer + Date

Date

Date + Date

Date

Date - Integer

Date

Date - Date

Integer

 

Examples

Date dAnniversary dSpousesBirthday dVacation dDeadline

This example declares four date variables: dAnniversary, dSpousesBirthday, dVacation, and dDeadline.

 

Date[] dBirthdays

This example declares 1 dynamic array variable, named dBirthdays, containing an undefined number of elements of type date.

Date[5] dBirthdays

This example declares 1 static array variable, named dBirthdays, containing 5 of elements of type date.

Date[][3] dBirthdays

This example creates a two-dimensional dynamic array variable named dBirthdays, containing an undefined number of elements of type date. Conceptually, this represents a rectangular array with an undefined number of rows, each of 3 columns.

You can declare dynamic multi-dimensional arrays where all dimensions are dynamic; these are called jagged arrays.

Notes

 

Object oTest Is A Button

 

    Function DaysAgo Date dSomeDate Returns Integer

        Date dToday

        Integer iDaysBetween

 

        SysDate dToday

        Move (dToday - dSomeDate) To iDaysBetween

 

        Function_Return iDaysBetween

    End_Function 

 

    Procedure Test Date dTest

        Integer iDaysAgo

 

        Move (DaysAgo(self, dTest)) To iDaysAgo 

        If (iDaysAgo > 0); 

            Showln dTest " was " iDaysAgo " days ago." 

        Else; 

            Showln dTest " is " (-iDaysAgo) " days from now." 

    End_Procedure 

 

    Procedure OnClick 

        // Test various 2 and 4 digit dates. 

        Send Test "01/01/1980" 

        Send Test "01/01/80" 

        Send Test "01/01/2000" 

        Send Test "01/01/00" 

        Send Test "01/01/2010" 

        Send Test "01/01/10" 

    End_Procedure 

 

End_Object