Re: Age calculation script

2006-09-09 Thread Jim Ault
Sarah Reichelt has dealt with the various ways of doing date calcs on computer operating systems and has more info on her web site at www.troz.net. (See below) The basic issues are that different platforms regard two-digit years differently, and time/date functions will fail at some point in the p

Re: Age calculation script

2006-09-09 Thread Graham Samuel
On Fri, 8 Sep 2006 14:22:43 +0200, "William de Smet" <[EMAIL PROTECTED]> wrote: Hi there, For an educational app I want to calculate someone's age based on date of birth and todays date but I don't know how to start! I made a field in which the user puts its 'date of birth' (dd/mm/yy) and a

Re: Age calculation script

2006-09-09 Thread Roger . E . Eller
Jim Ault wrote: > Try this loop, then look at the msgbox, or copy paste to another app > > on showDateList > put the short date into noww > convert noww to seconds >put 24*60*60 into hr24 >repeat with x = (35*365) to (100*365) > put noww - (x*hr24) into past > convert past to dat

Re: Age calculation script

2006-09-09 Thread Jim Ault
Ouch! I can get the date list to go back 101 years from today without a problem. Wonder why the difference in dateItems between [2.7.2 OSX 10.4.9] <> [Win 2000 2.6.1 or Win 2000 2.7.3] Jim Ault Las Vegas On 9/9/06 12:09 PM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >>I tried it in 2

Re: Age calculation script

2006-09-09 Thread Roger . E . Eller
> Try this loop, then look at the msgbox, or copy paste to another app > > on showDateList > put the short date into noww > convert noww to seconds >put 24*60*60 into hr24 >repeat with x = (35*365) to (100*365) > put noww - (x*hr24) into past > convert past to dateitems > put

Re: Age calculation script

2006-09-09 Thread Jim Ault
Must be something about the system we don't understand. I am on Rev 2.7.2, OSX 10.4.7 Try this loop, then look at the msgbox, or copy paste to another app on showDateList put the short date into noww convert noww to seconds put 24*60*60 into hr24 repeat with x = (35*365) to (100*365)

Re: Age calculation script

2006-09-09 Thread Roger . E . Eller
>> It appears that any birth year before 1970 results in an incorrect >> calculation. Entering 5/18/65, the result is: days old = 54750 years old = >> 149 exact years old = 149.945205 next >> Bday = 20 days from now >> > H, my version seems to work fine. Maybe I did a typo or something

Re: Age calculation script

2006-09-09 Thread Jim Ault
On 9/9/06 10:21 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 9/9/06 12:03 PM, "Jim Ault" <[EMAIL PROTECTED]> wrote: >> Here is my version using the approach of 'dateitems' >> This rendition *should* do things correctly and accommodate leap years. >> It will also calculate days till next

Re: Age calculation script

2006-09-09 Thread Roger . E . Eller
On 9/9/06 12:03 PM, "Jim Ault" <[EMAIL PROTECTED]> wrote: > Here is my version using the approach of 'dateitems' > This rendition *should* do things correctly and accommodate leap years. It > will also calculate days till next birthday. It appears that any birth year before 1970 results in an inc

Re: Age calculation script

2006-09-09 Thread Jim Ault
rt bd to dateItems >put actualBdYr into item 1 of bd >convert asOf to dateItems >put actualNowYr into item 1 of asOf >put item 1 of bd into bYr >put item 2 of bd into bMo >put item 3 of bd into bDy >put item 1 of asOf into nYr >put item 2 of as

Re: Age calculation script

2006-09-08 Thread Peter Brigham
y put item 1 of asOf into nYr put item 2 of asOf into nMo put item 3 of asOf into nDy if bDy > nDy then subtract 1 from nM if bMo > nMo then subtract 1 from nY put nYr - bYr into age return age end doAge ******** On Fri, 8 Sep 2006 14:44:38 +0100 Mark Smith <

Re: Age calculation script

2006-09-08 Thread Mark Smith
On 8 Sep 2006, at 15:07, Mark Smith wrote: This is to do with where the centuryCutoff is - if you set it to 5, you should get the expected answer (100 yrs, 0 months), I think. I should have added that 9/1/1906 is not really a valid short date, I don't think - I think the engine simply take

Re: Age calculation script

2006-09-08 Thread Mark Smith
This is to do with where the centuryCutoff is - if you set it to 5, you should get the expected answer (100 yrs, 0 months), I think. best Mark On 8 Sep 2006, at 14:55, [EMAIL PROTECTED] wrote: 2006/9/8, Mark Smith <[EMAIL PROTECTED]>: function getAge bDay put 60 * 60 * 24 * 365 into sec

Re: Re: Age calculation script

2006-09-08 Thread Roger . E . Eller
2006/9/8, Mark Smith <[EMAIL PROTECTED]>: > function getAge bDay >put 60 * 60 * 24 * 365 into secsPerYear >put secsPerYear / 12 into secsPerMonth > >put the seconds into tDay > >-- assuming date of birth is given in short system date format >convert bDay from short system date t

Re: Age calculation script

2006-09-08 Thread Mark Smith
replacing put 60 * 60 * 24 * 365 into secsPerYear with put (60 * 60 * 24 * 365) + (60 * 60 * 6) into secsPerYear ie. adding a quarter of a days seconds to sescPerYear seems to fix it, at least for age < 30ish. Best, Mark On 8 Sep 2006, at 14:36, Mark Smith wrote: Actually, the other way

Re: Age calculation script

2006-09-08 Thread Mark Smith
Great! Actually, the other way it is likely to be wrong is when today's date is very close to the persons birthday - eg if a persons age is really 16 yrs 11 months, and their birthday is a couple of days from now, it may give 17 yrs 0 months. These date/period things can be tricky, so you h

Re: Re: Age calculation script

2006-09-08 Thread William de Smet
Thanks Mark, It works! Like I said it's an educational stack so the pupils/students are not older than 20 so leap years are not important. greetings, William de Smet 2006/9/8, Mark Smith <[EMAIL PROTECTED]>: function getAge bDay put 60 * 60 * 24 * 365 into secsPerYear put secsPerYear

Re: Age calculation script

2006-09-08 Thread Mark Smith
function getAge bDay put 60 * 60 * 24 * 365 into secsPerYear put secsPerYear / 12 into secsPerMonth put the seconds into tDay -- assuming date of birth is given in short system date format convert bDay from short system date to seconds put tDay - bDay into tAgeInSecs put tAgeInSe