Impressive - you got the "other" leap year that most folks forget, the 400 one. Umm, I guess nobody could be expected to remember from experience, though.
Later, Steve in Memphis > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On > Behalf Of MikeB > Sent: Thursday, March 21, 2002 12:54 PM > To: [EMAIL PROTECTED] > Subject: Age Calculation > > > In Dec., an accountant wanted to refer to the age of his client. To > accurately show the age of anyone on a given date, the precise > determination > of leap year comes into play. A Stored proc was created of the following: > > Procedure : sp_age > Description : > ID : 3 > Last Modified: December 13, 2001 6:17 PM > Version : 1 > > Parameter Name Parameter Attributes > -------------------- > ----------------------------------------------------- > ---- > vdatein Type : DATE > > Procedure has 1 parameters. > Return Value: Type : INTEGER > > The Code of the Procedure is this: > > --Begin Code: > *(spAge mod 121301 mbyerley) > *(returns int years) > CLEAR VAR MICRORIM_RETURN,stp_return,vage,vagedays,vageyr, + > vlp,vthisdays,vthisyr,vyr > SET VAR vdatein DATE > SET VAR vage INTEGER = NULL > IF vdatein IS NULL THEN > SET VAR vage = 0 > ELSE > SET VAR vthisyr INTEGER = (INT((SGET((CTXT((JDATE(.#DATE)))),4,1)))) > SET VAR vthisdays INTEGER = > (INT((SGET((CTXT((JDATE(.#DATE)))),3,5)))) > SET VAR vageyr INTEGER = (INT((SGET((CTXT((JDATE(.vdatein)))),4,1)))) > SET VAR vagedays INTEGER = > (INT((SGET((CTXT((JDATE(.vdatein)))),3,5)))) > -- check for leap year > SET VAR vyr = (IYR(.vdatein)) > SET VAR vlp INTEGER = NULL > IF ((MOD(.vyr,4)) = 0 AND (MOD(.vyr,100)) <> 0) + > OR (MOD(.vyr,400)) = 0 THEN > -- True > SET VAR vlp = 1 > ELSE > -- False > SET VAR vlp = 0 > ENDIF > SET VAR vagedays = (.vagedays - .vlp) > -- dayofyear is < birthday age is year minus birthyear minus 1 > IF vthisdays < .vagedays THEN > SET VAR vage = ((.vthisyr - 1) - .vageyr) > -- dayofyear is after or on birthday age is year minus birthyear > ELSE > --dayofyear is on birthday or after age is year minus birthyear > SET VAR vage = (.vthisyr - .vageyr) > ENDIF > ENDIF > CLEAR VAR vagedays,vageyr,vdatein,vlp,vthisdays,vthisyr,vyr > RETURN .vage > > --End Code: > > > It is called by the following: > The Var vDateIN is set as a Date DataType to the Birthdate > > Set Var vDateIN date = 04/17/1944 > > Then: > > Set Var vAge = (call Sp_Age(.vDateIn)) > > Var vAge is returned properly..... > > > > ================================================ > TO SEE MESSAGE POSTING GUIDELINES: > Send a plain text email to [EMAIL PROTECTED] > In the message body, put just two words: INTRO rbase-l > ================================================ > TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED] > In the message body, put just two words: UNSUBSCRIBE rbase-l > ================================================ > TO SEARCH ARCHIVES: > http://www.mail-archive.com/rbase-l%40sonetmail.com/ > ================================================ TO SEE MESSAGE POSTING GUIDELINES: Send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: INTRO rbase-l ================================================ TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: UNSUBSCRIBE rbase-l ================================================ TO SEARCH ARCHIVES: http://www.mail-archive.com/rbase-l%40sonetmail.com/
