A type 6 date is stored as CHR(CC) + CHR(YY) + MMDD. This script reads one from a link, turns it into a YYYYMMDD string and converts it to a number with DTN, so you can do date arithmetic or store it as an SQL-style date.

! CHANGES FROM DATE TYPE 6 TO A NUMBER
LN BTLDATE6
MAINLINE
OPEN LINK BTLDATE6
READ BTLDATE6 USING KEY "11111" !read link using pre-defined key
LET A$ = DATE !let A$ equal the type 6 date
!which is stored as...
!CHR(CC) + CHR(YY) + MMDD
LET B$=STR(ASC(A$(1,1))) !let B$ equal string of CHR(CC)
LET C$=STR(ASC(A$(2,1))) !let C$ equal string of CHR(YY)
LET D$=A$(3,4) !let D$ equal string of MMDD
IF LEN(C$)=1 !test to see if C$ is a one digit
!number.
THEN
LET E$=B$+"0"+C$+D$ !if C$ is one digit, place the
!zero before it and add the string
!of each number
ELSE
LET E$=B$+C$+D$ !if C$ is not one digit, add the
!string of each number
ENDIF
LET N = DTN(E$,"YYYYMMDD") !gets the number from the string
!using the mask
LET N$ = NTD(N,"YYYYMMDD") !gets the date from the number
!using the mask
PRINT N, N$
INPUT *

Notes

The example reads link BTLDATE6 with the key “11111” and uses its DATE data name. Replace them with your own link, key and date field.

Search tbred.com