Handle Dates before 1900 and beyond 2000 in the Same Procedure

Top  Previous  Next

When your program lets users input dates, it should do so as intelligently as possible. If your program is intelligent and flexible in accepting dates, your end users will appreciate it. For example, forcing your end users to input dates in a rigid dd/mm/yyyy format (or any fixed format) not only slows them down, it can lead to cursing and other expressions of frustration when dates are misinterpreted or rejected altogether.

The keys to intelligent date handling with Clarion are the entry field picture token and Clarion's automatic date parsing functions. Date Notation picture tokens let you display dates in a number of different formats. Better still, date picture tokens in entry fields automatically invoke Clarion's run-time date parsing functions, so you can enter '21' and Clarion expands it to the 21st day of the current month and year. Or you can enter 'DEC' and Clarion expands it to the 1st day of December of the current year. Clarion then formats the expanded date according to the picture token.

 

The MASK attribute (Entry Patterns check box) on a window preempts the automatic date parsing functions and forces the user to enter the date in the form of the date picture.

To illustrate, lets look at two different examples: a field containing employee birthdates and a field containing commercial real estate lease expiration dates.

Birthdates from 1900 to 2000

The birthdate field is likely to contain dates ranging from the early 1900's to about 1980, and, since your application may be in use for another 10 years, you should probably extend the upper end of this range to 1990 or even 2000.

You want to let your end users input the year of birth without having to explicitly specify the century. For example, in 1997, your program should interpret an entry of 1/1/15 as January 1, 1915 and not as January 1, 2015.

By default, Clarion assumes that a year specified without the century falls within the 100 year period from today-80 years to today+19 years. Thus in 1997, Clarion assumes dates entered fall between 1917 and 2016. This default, as illustrated by our example entry (1/1/15) is not appropriate for your birthday field. However, you can use a date notation picture token to change the default to fit your particular application.

The assumed 100 year period is always relative to today's date. Therefore, a picture token that is valid for employee birthdays today will also be valid 10 years from today.

To specify an intelligent assumed date range to handle employee birthdays, simply add <99 to your preferred date picture token:

@D1<99

You may specify the picture token by typing it into the Picture field in the Entry Properties dialog, or by pressing the Picture field's ellipsis (...) button to open the Edit Picture String dialog. In the Edit Picture Sting dialog, choose your preferred date format, then set the Two digit date range to 99.

Now, for this field, Clarion assumes that a year specified without the century falls within the 100 year period between today-99 years and today+1 year. So, for birthdays entered in 1997, Clarion assumes the birth year falls between 1898 and 1998, and for birthdays entered in 2007 (10 years from now), Clarion assumes the birth year falls between 1908 and 2008.

Lease Expirations from 1997 to 2096

The lease expiration field is likely to contain dates ranging from the current year (1997) to 99 years in the future (2096).

You want to let your end users input the lease expiration year without having to explicitly specify the century. For example, in 1997, your program should interpret an entry of 1/31/55 as January 31, 2055 and not as January 31, 1955.

By default, Clarion assumes that a year specified without the century falls within the 100 year period from today-80 years to today+19 years. Thus in 1997, Clarion assumes dates entered fall between 1917 and 2016. This default, as illustrated by our example entry (1/31/55) is not appropriate for your lease expiration field. However, you can use a date notation picture token to change the default to fit your particular application.

The assumed 100 year period is always relative to today's date. Therefore, a picture token that is valid for lease expirations today will also be valid 10 years from today.

To specify an intelligent assumed date range to handle lease expirations, simply add <0 (or >99) to your preferred date picture token:

@D1<0

You may specify the picture token by typing it into the Picture field in the Entry Properties dialog, or by pressing the Picture field's ellipsis (...) button to open the Edit Picture String dialog. In the Edit Picture Sting dialog, choose your preferred date format, then set the Two digit date range to 0.

Now, for this field, Clarion assumes that a year specified without the century falls within the 100 year period between today-0 years and today+99 years. So, for lease expirations entered in 1997, Clarion assumes the year falls between 1997 and 2096, and for lease expirations entered in 2007 (10 years from now), Clarion assumes the year falls between 2007 and 2106.