BBS: Inland Empire Archive Date: 06-14-92 (09:53) Number: 422 From: DICK DENNISON Refer#: 413 To: JOHN GALLAS Recvd: NO Subj: Re: formula Conf: (2) Quik_Bas
JG> I need a forumla that'll tell how many days its been between two
JG> dates. It has to tell weather it has been a leap year or not, and it
JG> has to be fast. Is it possible? Any help would be appreciated.
This may help:
FUNCTION jdn& (dater$)
YY% = VAL(MID$(dater$, 9, 2))
MM% = VAL(MID$(dater$, 1, 2))
DD% = VAL(MID$(dater$, 4, 2))
NumLeap% = YY% \ 4
IF YY% MOD 4 = 0 THEN
NumLeap% = NumLeap% - 1
IsLeap% = 1
ELSE
IsLeap% = 0
END IF
SELECT CASE MM%
CASE 1: J& = DD%
CASE 2: J& = DD% + 31
CASE 3: J& = DD% + 59 + IsLeap%
CASE 4: J& = DD% + 90 + IsLeap%
CASE 5: J& = DD% + 120 + IsLeap%
CASE 6: J& = DD% + 151 + IsLeap%
CASE 7: J& = DD% + 181 + IsLeap%
CASE 8: J& = DD% + 212 + IsLeap%
CASE 9: J& = DD% + 243 + IsLeap%
CASE 10: J& = DD% + 273 + IsLeap%
CASE 11: J& = DD% + 304 + IsLeap%
CASE 12: J& = DD% + 334 + IsLeap%
END SELECT
J& = J& + (YY% - 1&) * 365 + NumLeap%
jdn& = J&
END FUNCTION
--- VP [DOS] V4.09e
* Origin: The MailMan (914)374-3903 NY Quick Share Pt #7 *HST (1:272/34)

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