BBS: Inland Empire Archive Date: 04-16-92 (02:54) Number: 80 From: RICK PEDLEY Refer#: NONE To: GARY POOL Recvd: NO Subj: Date Routine Question Conf: (2) Quik_Bas
On 04-13-92 GARY POOL wrote to All... GP> Does anyone have a good routine that will t/XX/+aUke+a/ll/ the day of GP> the week from the date? (Sorry, a lot of line noise today). GP> GP> For example, Call DayOfWeek$(Date$) would call a Function DayOfWeek$ GP> that would return Monday, Tuesday, Wednesday, etc. A friend of mine did GP> it in assembler on the host, but if I ask him for the algorithm, he will GP> harrass me to no end. I'm sure that this is something that has been GP> done many times before, so I'd rather not reinvent the wheel. Thanks in GP> advance. gp This'll do it. It's not my code, BTW. I think I translated it from an Applesoft listing in a Nibble magazine. Also calculate # of days between two dates. 'Calculates number of days between any two dates and gives day of week 'for both dates. DEFINT A-Z 'any variable without a type identifier is a short integer. '& means long integer Days$ = "FRISATSUNMONTUEWEDTHU" W& = 0 FOR I = 1 TO 2 INPUT "MM,DD,YYYY: ", M, D, Y X = -INT((1 / (M + 1) + .7)) Z& = INT((M + 1 - 12 * X) * 30.6001) + INT((Y + X) * 365.25) + D X = Z& - 7 * (Z& \ 7) DayOfWeek$ = MID$(Days$, X * 3 + 1, 3) PRINT DayOfWeek$ W& = Z& - W& NEXT I PRINT W&; "days between the two dates." ... OFFLINE 1.36 * I just found the last bug. --- Maximus 2.01wb * Origin: The BULLpen BBS * Intel 14.4EX (613)549-5168 (1:249/140)
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