suprtool.com

Standard Date function in Suprtool

Treats all dates the same way, regardless of the date format

Users who have dates with two-digit years will now be able to use Suprtool's new $stddate function to select and manipulate records as if the dates had four-digit years. The new function uses date windowing that can be specified either globally or per task to decide which century the two-digit year is in. It also can be used to do many new tasks:

$stddate is available to the If and Extract commands. It internally converts any date format (including A0 date format) in nearly any data-type container to the ccyymmdd format in a double integer container.

Compare between dates of dissimilar formats

    > get invoice-detail
    > set date cutoff 30
    > item invoice-date,date,yymmdd
    > item close-date,date,mmddyyyy
    > if $stddate(close-date) <= $stddate(invoice-date)
    > out badinvs,link
    > xeq

In this case all invoice dates with a yy value between 30 and 99 will have 19 as the century. All invoice dates with a yy value of less than 30 will have 20 as the century generated by the $stddate function.

Update six-digit dates in any format to eight-digit CCYYMMDD dates

    > get invoice-detail
    > set date cutoff 30
    > item  invoice-date,date,yymmdd
    > if not $invalid(invoice-date)
    > update
    > extract invoice-date = $stddate(invoice-date)
    > xeq

In this case the invoice-date field would need to have room for the 2 extra digits. e.g. Image data type J2 or Z8.

Create extracts with four-digit years from records with two-digit years

    > get invoice-detail
    > set date cutoff 30
    > item  invoice-date,date,yymmdd
    > define new-date-8,1,8,display      {temporary numeric field}
    > extract  new-date-8 = $stddate(invoice-date)
    > extract  first-field / last-field
    > ...

In this case we define a new numeric data field, new-date-8, to hold the converted invoice-date.

Compare six-digit dates to system date variables after Dec 31, 1999.

    > get invoice-detail
    > item  invoice-date,date,yymmdd
    > if $stddate(invoice-date) >= $date(*+2/*/*)    {two years from now}
    > ...

Tasks like this that crossed centuries would not work in previous versions of Suprtool.

Do less-than and greater-than comparisons on non-collating dates.

    > get invoice-detail
    > item close-date,date,mmddyyyy
    > if $stddate(close-date) < $today
    > ...

Until now, Suprtool has refused to permit less-than and greater-than comparisons of dates that are not stored in naturally sorting order. E.g., ddmmyy and mmddyy dates were specifically excluded. The $stddate function lets you get around that.

Note that $stddate is not available in the Sort command, so you need two (or more) passes.

Sorting on six-digit dates, using multiple passes.

    > get invoice-detail
    > item close-date,date,mmddyy
    > extract first-field / last-field
    > define new-field,1,8,integer
    > extract new-field = $stddate(close-date)
    > output foo,temp,link
    > xeq
    >
    > input foo
    > sort new-field
    > extract first-field / last-field
    > output myfile
    > xeq

Sorting on non-collating dates (e.g., ddmmyy or mmddyyyy) was not possible until now. Suprtool would accept the commands, but would not produce the desired results. Now it can be done, using multiple passes and $stddate:

Availability of $stddate

The new $stddate function was part of Suprtool version 4.2 released in April 1999. It is present in all later versions of Suprtool.

....Back to the Suprtool Q&A Page