Suprtool 4.2 (and later) has a feature that can greatly help in date selection and conversion. In previous versions there had been a few cases in which, for performance reasons, Suprtool could not manipulate dates the way that users needed. For example, it was not possible to do greater-than or less-than selection against dates that were in month-first or day-first format, nor was it possible to compare dates that were not in the same format.
One of the criteria for an acceptable solution was finding a way that did not slow Suprtool down for people who did not need this functionality. The $stddate function takes care of this, without affecting people who do not need it, by letting you decide when to take advantage of it. $Stddate converts dates from any of the formats that Suprtool recognizes to a common standard format, ccyymmdd.
With this conversion, it becomes possible to compare two dates that are not in the same format. And because $stddate puts century and year first, you can reliably do greater-than and less-than comparisons.
When $stddate converts a centuryless date format to ccyymmdd, it needs to 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 can be used in two places in Suprtool. In the If command it is used for selecting records based on date criteria. In the Extract command it is used for converting dates to the standard ccyymmdd format.
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.
get shipping-records 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.
get shipping-records 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 output myfile,link xeqWhat 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 will be 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) & and $stddate(date-shipped) > $stddate(order-date)The Robelle Web site also has more detailed information about $stddate.