BBS: Inland Empire Archive Date: 03-27-93 (10:38) Number: 227 From: JOE NEGRON Refer#: NONE To: JIM COYLE Recvd: NO Subj: Blah. Conf: (2) Quik_Bas
JC> Does anyone have a Date2Int function that could be posted? Thanks.
Ask and ye shall receive...
============================== Begin code ==============================
DEFINT A-Z
DECLARE FUNCTION Date2Day% (DateX$)
DECLARE FUNCTION Date2Mth% (DateX$)
DECLARE FUNCTION Date2Serial& (DateX$)
DECLARE FUNCTION Date2Year% (DateX$)
'***********************************************************************
'* FUNCTION Date2Day%
'*
'* PURPOSE
'* Returns the day number given a date in the standard date format.
'***********************************************************************
FUNCTION Date2Day% (DateX$) STATIC
Date2Day% = VAL(MID$(DateX$, 4))
END FUNCTION
'***********************************************************************
'* FUNCTION Date2Mth%
'*
'* PURPOSE
'* Returns the month number given a date in the standard date format.
'***********************************************************************
FUNCTION Date2Mth% (DateX$) STATIC
Date2Mth% = VAL(DateX$)
END FUNCTION
'***********************************************************************
'* FUNCTION Date2Serial&
'*
'* PURPOSE
'* Returns the astronomical Julian day number given a date in the
'* standard date format. Note that the year must be 1583 or greater.
'*
'* INTERNAL ROUTINE(S)
'* FUNCTION Date2Day% (DateX$)
'* FUNCTION Date2Mth% (DateX$)
'* FUNCTION Date2Year% (DateX$)
'***********************************************************************
FUNCTION Date2Serial& (DateX$) STATIC
Month% = Date2Mth%(DateX$)
Day% = Date2Day%(DateX$)
Year% = Date2Year%(DateX$)
IF Month% > 2 THEN
Month% = Month% - 3
ELSE
Month% = Month% + 9
Year% = Year% - 1
END IF
TA& = 146097 * (Year% \ 100) \ 4
TB& = 1461& * (Year% MOD 100) \ 4
TC& = (153 * Month% + 2) \ 5 + Day% + 1721119
Date2Serial& = TA& + TB& + TC&
END FUNCTION
'***********************************************************************
'* FUNCTION Date2Year%
'*
'* PURPOSE
'* Returns the year number given a date in the standard date format.
'***********************************************************************
FUNCTION Date2Year% (DateX$) STATIC
Date2Year% = VAL(MID$(DateX$, 7))
END FUNCTION
=============================== End code ===============================
--Joe in Bay Ridge, Brooklyn, NY, Sat, 03-27-1993--
... Diplomacy: Saying "nice doggie"...until you find a rock.
___
X Blue Wave/QWK v2.12 X
--- Maximus 2.01wb
* Origin: * BlueDog BBS * (212) 594-4425 * NYC FileBone Hub (1:278/709)

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