Get the most out of your Robelle Tools
Dealing with Non-Standard Dates in Suprtool
Suprtool has a feature that can greatly help in date selection and conversion, even greater-than or less-than selection against dates that are in month-first or day-first format, and comparing dates that are not in the same format.
And the solution does not slow Suprtool down for people who do not need this functionality. The $stddate function takes care of everything, by letting you decide when to invoke it. $Stddate converts dates from any of the formats that Suprtool recognizes into a common standard format, ccyymmdd.
When $stddate converts a date without century (if you have any of those left after Y2K!) to ccyymmdd, it must decide what century to add. This is determined by the Set Date Cutoff command, which defines the starting year of a 100-year date window. The default year is 10, which means that incoming yy values of 10 through 99 will have century 19 applied, and incoming yy values of 00 through 09 will have century 20 applied. If you set the cutoff value to 50, the 100-year span would go from 1950 through 2049, with century applied accordingly.
$Stddate is used in two places in Suprtool in the If command for selecting records based on date criteria, and in the Extract command for converting dates to the standard ccyymmdd format.
Now lets see some examples.
Comparing Two Dissimilar Dates
When Suprtool compares two fields to each other, it does not try to interpret them. If they are character fields, it just compares the bytes. If they are numeric fields, it just compares the numeric values. Using $stddate forces Suprtool to convert the date fields to a common format before comparing them.
>item order-date, date, mmddyy
>item date-shipped, date, ddmmyyyy
>if $stddate(date-shipped) > $stddate(order-date)
Converting Dates to CCYYMMDD Format
Suprtool can convert any known date formats to the standard ccyymmdd format. This is done by using $stddate in the Extract command. The date being converted must be defined as a numeric field. You need to define an eight- digit numeric container to receive the converted date.
>item order-date, date, mmddyy
>define converted-date, 1, 8, display
>extract converted-date = $stddate(order-date)
If you are creating a self-describing (link) output file, remember to tell Suprtool that the new field is in ccyymmdd format.
>item converted-date, date, ccyymmdd
What About Invalid Dates?
Something to keep in mind is that the $stddate function can only convert dates that are valid. A valid date is one that appears on the calendar.
Therefore special dates such as all zeros, blanks, nines, etc. will need special attention. Any dates that are not valid are converted to zero by $stddate.
You need to be aware of this when you design your Suprtool task. You can ensure that $stddate sees only valid dates by filtering out the invalid ones with the $invalid function.
>if not $invalid(date-shipped) and not $invalid(order-date) &
$stddate(date-shipped) > $stddate(order-date)
Copyright The 3000 NewsWire. All rights reserved.