Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accurately calculating a persons age
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00953701
Message ID:
00954198
Views:
25
Will this code work for you?
Lparameters BirthDate,YearsLimit
Local llok, MoLimit, MonthOld
MoLimit = YearsLimit * 12	&& Number of total month within limit
MonthOld = 12 * (Year(Date()) - Year(BirthDate))	&& Total Months between years
MonthOld = MonthOld + 12 - Month(BirthDate) + Month(Date())	&& Month difference add to years difference
*? 'MoLImit=',molimit,MonthOld
Do Case
Case MonthOld > MoLimit
	llok = .T.
Case MonthOld < MoLimit
	llok = .F.
Otherwise
	llok = Day(BirthDate) => Day(Date())	&& Check day of month
Endcase
Return llok
>The system I am writing needs to validate people applying for an account as being 18 years old or older. Anyone under 18 should not be allowed an account. It sounds simple, but one of my versions that included detection of leap years got very complicated, hence my question here.
>
>Simon
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform