You can perform calculations with data types other than money or real. When you use date fields in a formula, you can compare two date fields with each other. Subtracting one date field from another results in the number of days between the two dates. Adding a number to a date field gives the date that many days past the date in the date field. Subtracting a number from a field of type date gives the date that many days before the date in the field. Figure 6 shows some calculated fields examples using dates.
Form Name ex6
Data File
Beginning form no Unique records no
Repeating form no Append form no
Freeze form no Additional form no
Required form no for one record
Next form name ex6
Field name date1 Field length 8
Entry Allowed yes Input required no
In Data File no Invisible no
Edit/Match test date1 < oldest "date too old"
test date1 > newest "date too new"
Edit Data Type date
Field name diff Field length 7
Entry Allowed no Input Required no
In Data File no Invisible no
Calculation date1-today
Edit Data Type integer
Field name greater Field length 3
Entry Allowed no Input required no
In Data File no Invisible no
Calculation date1>today
Edit Data Type boolean
Field name date2 Field length 8
Entry Allowed no Input required no
In Data File no Invisible no
Calculation date1+5
Edit Data Type date
Field name today Field length 8
Entry Allowed no Input required no
In Data File no Invisible no
Initial value TODAY
Edit Data Type date
Field name oldest Field length 8
Entry Allowed no Input required no
In Data File no Invisible no
Initial value 1/1/1900
Edit Data Type date
Field name newest Field length 8
Entry Allowed no Input required no
In Data File no Invisible no
Initial value TODAY
Edit Data Type date
Figure 6
The today field has an initial value of TODAY, Which form replaces with the current date. This field is used for calculations with the entered date field, date1. Note again the use of the Edit Field Types field to declare the data type of each field.
The two fields oldest and newest contain initial values that represent the oldest and newest valid values for the date1 field. The date1 field is edited with the following formula
test date1 < oldest "date to old"
test date1 > newest "date to new"
In a real application, you would make the today, oldest, and newest fields Invisible yes, so the operator would not see them.
The same kinds of calculations can be done with time fields. Two time fields may be compared with each other. Subtracting one time field from another results in the number of seconds between the two times. Adding a number to a time field gives the time that many seconds past the value in the time field. Subtracting a number from a time field gives the time that many seconds before the time in the field.