> On 12/17/12 10:46 AM, Andre Garzia wrote: > > > the function is called elapsed and you can use it to figure out if a > > certain amount of time passed between two timestamps.
> Jacquie wrote... > I'd like a function that returns years, months, and days elapsed. I > wrote a quick one that gets the number of days and divides by 30 to get > months and days but it isn't very accurate. Since it's just for me I > haven't gone back to fix it. Anyone have one already written? >From The Scripter's Scrapbook... FUNCTION calcAccAge tBirthdate,tAsOf IF tAsOf = "" THEN put the short date into tAsOf END IF convert tBirthdate to dateItems convert tAsOf to dateItems put item 1 of tAsOf - item 1 of tBirthdate into item 1 of tYrMthday put item 2 of tAsOf - item 2 of tBirthdate into item 2 of tYrMthDay put item 3 of tAsOf - item 3 of tBirthdate into item 3 of tYrMthday IF (item 3 of tYrMthDay < 0) THEN put tAsOf into tHowManyDays -- here's the cool bit. 0 in item 3 of date items effectively gives you -- how many days in the month before put 0 into item 3 of tHowManyDays convert tHowManyDays to dateItems put item 3 of tHowManyDays + item 3 of tYrMthDay into item 3 of tYrMthDay -- when days are - we need to subtact 1 from the month count put item 2 of tYrMthDay - 1 into item 2 of tYrMthDay END IF IF (item 2 of tYrMthDay < 0) THEN -- used to convert a negative month count into a positive number put 12 + item 2 of tYrMthDay into item 2 of tYrMthDay -- when month is negative need to subtact 1 from yr count put item 1 of tYrMthDay - 1 into item 1 of tYrMthDay END IF return tYrMthDay END calcAccAge Hugh Senior FLCo _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode