A type 7 date is stored as CHR(YY+1) + CHR(MM+1) + CHR(DD+1). This program decodes one into a YYMMDD string, then converts it to a number with DTN and back with NTD.
00005 REM " Change from date type 7 to a number00010 A$=CHR(97+1)+CHR(11+1)+CHR(1+1) !let A$ equal a pre-defined type 7 date !which is stored as... !CHR(YY+1) + CHR(MM+1) + CHR(DD+1)
00020 B$=STR(ASC(A$(1,1))); !let B$ equal the string of the year C$=STR(ASC(A$(2,1))); !let C$ equal the string of the month D$=STR(ASC(A$(3,1))) !let D$ equal the string of the day
00030 BB$=STR(NUM(B$)-1); !subtract 1 from the string of BB$ CC$=STR(NUM(C$)-1); !subtract 1 from the string of CC$ DD$=STR(NUM(D$)-1) !subtract 1 from the string of DD$
00035 IF LEN(BB$)=1 !test to see if the year is one digit BBB$="0" !if it is, place a zero before it ELSE BBB$=""00040 IF LEN(CC$)=1 !test to see if the month is one digit CCC$="0" !if it is, place a zero before it ELSE CCC$=""00045 IF LEN(DD$)=1 !test to see if the day is one digit DDD$="0" !if it is, place a zero before it ELSE DDD$=""00050 E$=BBB$+BB$+CCC$+CC$+DDD$+DD$ !let E$ equal the sum of the strings00055 N=DTN(E$,"YYMMDD"); !let N equal the number from the string N$=NTD(N,"YYMMDD") !let N$ equal the date from the number00060 PRINT N,N$00070 INPUT *Notes
Line 00010 builds a sample type 7 date (November 1, 1997). In your own program, take the three bytes from your data instead.