BBS: Inland Empire Archive Date: 08-11-92 (22:54) Number: 18 From: DOUG NANNEN Refer#: NONE To: ALL Recvd: NO Subj: Lotus functions @date() a Conf: (2) Quik_Bas
'LOTUS DATE FUNCTIONS @DATE() AND @DATEVALUE() '08-11-1992 = 33827 DECLARE FUNCTION DATESTRING$ (Z) DECLARE FUNCTION DATEVALUE (M$) CLS T = DATEVALUE("NOW") FOR A = T TO T + 6 STEP 1 B$ = DATESTRING$(A) C = DATEVALUE(B$) PRINT B$, C NEXT A FUNCTION DATESTRING$ (Z) DEFINT A-Y STATIC CK, DATE() IF CK = 0 THEN DIM DATE(12) DATE(1) = 31: DATE(2) = 28: DATE(3) = 31: DATE(4) = 30 DATE(5) = 31: DATE(6) = 30: DATE(7) = 31: DATE(8) = 31 DATE(9) = 30: DATE(10) = 31: DATE(11) = 30: DATE(12) = 31 CK = 1 END IF Z6 = Z IF Z <> INT(Z) THEN ERROR 5 IF Z < 1 OR Z > 73050 THEN ERROR 5 Z8 = Z6 / 365.25 Z9 = INT(Z8) * 365.25 IF Z9 = INT(Z9) THEN DATE(2) = 29 ELSE Z9 = Z9 + 1: DATE(2) = 28 Z9 = INT(Z9) XA = 1 DO WHILE XA + 1 < 13 AND Z9 + DATE(XA) < Z6 Z9 = Z9 + DATE(XA): XA = XA + 1 LOOP AX = XA + 1: IF Z6 = Z9 THEN Z6 = Z9 + 31: Z8 = Z8 - 1: XA = 12 X0 = Z6 - Z9 Z8 = INT(Z8) XT$ = MID$(STR$(XA), 2): IF VAL(XT$) < 10 THEN XT$ = "0" + XT$ XY$ = MID$(STR$(X0), 2): IF VAL(XY$) < 10 THEN XY$ = "0" + XY$ Z8 = Z8 + 1900 XZ$ = MID$(STR$(Z8), 2): IF VAL(XZ$) < 10 THEN XZ$ = "0" + XZ$ DATESTRING$ = XT$ + "-" + XY$ + "-" + XZ$ END FUNCTION DEFSNG A-Y FUNCTION DATEVALUE (M$) DEFINT A-Y STATIC CK, DATE() IF CK = 0 THEN DIM DATE(12) DATE(1) = 31: DATE(2) = 28: DATE(3) = 31: DATE(4) = 30 DATE(5) = 31: DATE(6) = 30: DATE(7) = 31: DATE(8) = 31 DATE(9) = 30: DATE(10) = 31: DATE(11) = 30: DATE(12) = 31: CK = 1 END IF I$ = M$ IF I$ = "NOW" THEN I$ = DATE$ IF I$ = "now" THEN I$ = DATE$ T$ = MID$(I$, 1): A1 = VAL(T$) T$ = MID$(I$, 4): A2 = VAL(T$) T$ = MID$(I$, 7): Z3 = VAL(T$) FOR T = 1 TO LEN(I$): T$ = MID$(I$, T, 1): V = ASC(T$) IF V < 48 OR V > 57 THEN C = C + 1 NEXT T IF C > 2 THEN ERROR 5 T$ = MID$(I$, 3, 1): IF T$ = "/" OR T$ = "-" THEN T$ = "" ELSE ERROR 5 T$ = MID$(I$, 6, 1): IF T$ = "/" OR T$ = "-" THEN T$ = "" ELSE ERROR 5 IF A1 < 1 OR A1 > 12 THEN ERROR 5 IF Z3 > 1899 AND Z3 < 2100 THEN Z3 = Z3 - 1900 IF Z3 < 0 OR Z3 > 199 THEN ERROR 5 Z2 = Z3 * 365.25 IF Z2 = INT(Z2) THEN DATE(2) = 29 ELSE Z2 = Z2 + 1: DATE(2) = 28 IF A2 < 1 OR A2 > DATE(A1) THEN ERROR 5 IF A1 <> 1 THEN FOR A = 1 TO A1 - 1: Z2 = Z2 + DATE(A): NEXT A END IF Z2 = INT(Z2 + A2) DATEVALUE = Z2 END FUNCTION --- Maximus 2.00 * Origin: The Line Source BBS, Maximus [CBCS] (717)236-1375) (1:270/116)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET