Re: Age & Anniversary Calculations

2012-05-24 Thread Phil Davis
You are completely welcome! Sarah is one of the sharper knives in the drawer (and community-minded). I'm not sure if she still reads the list but she is missed. Phil On 5/24/12 5:09 PM, Igor de Oliveira Couto wrote: Dear Phil, Thank you *so much* for this link: On 24/05/2012, at 10:51 AM,

Re: Age & Anniversary Calculations

2012-05-24 Thread Igor de Oliveira Couto
Dear Phil, Thank you *so much* for this link: On 24/05/2012, at 10:51 AM, Phil Davis wrote: > Another good resource for date & time calcs is Sarah Reichelt's DateTime.rev > library, which is pure LC: > >http://www.troz.net/rev/index.irev?category=Library#stacks > That is some very useful

Re: Age & Anniversary Calculations

2012-05-23 Thread Phil Davis
Another good resource for date & time calcs is Sarah Reichelt's DateTime.rev library, which is pure LC: http://www.troz.net/rev/index.irev?category=Library#stacks Phil Davis On 5/23/12 5:42 PM, Igor de Oliveira Couto wrote: Peter, thank you very much for the sqlite-based answers: On 24/

Re: Age & Anniversary Calculations

2012-05-23 Thread Igor de Oliveira Couto
Peter, thank you very much for the sqlite-based answers: On 24/05/2012, at 2:17 AM, Peter Haworth wrote: > Sorry about that Igor, not sure why it didn't make it. Anyway, here it is > again. [...] Indeed, it may be easier to let an external lib handle the date calculations, considering that it

Re: Age & Anniversary Calculations

2012-05-23 Thread Peter Haworth
Sorry about that Igor, not sure why it didn't make it. Anyway, here it is again. AGE CALCULATION (using 1945-07-06 as the birth date): SELECT (strftime('%Y','now') - strftime('%Y','1945-07-06')) - (strftime('%m'-%d','now') < strftime('%m-%d','1945-07-06')); CLOSE TO (Using 2012-05-30 as the ann

Re: Age & Anniversary Calculations

2012-05-22 Thread Igor de Oliveira Couto
On 23/05/2012, at 3:50 PM, Peter Haworth wrote: > I don't know the answer to your question about dates prior to 1970 on > Windows machines, but I do know that problem doesn't exist with the sqlite > solution I posted. [...] Peter, I went through my mail again to make sure, and I can't seem to fi

Re: Age & Anniversary Calculations

2012-05-22 Thread Peter Haworth
HI Igor, I don't know the answer to your question about dates prior to 1970 on Windows machines, but I do know that problem doesn't exist with the sqlite solution I posted. You don't even have to have an sqlite database available to you, just call revOpenDatabase with ":memory:" as the file path.

Re: Age & Anniversary Calculations

2012-05-22 Thread Igor de Oliveira Couto
Many thanks for all the suggestions - and I did learn a couple of new tricks from your code, too! I had not realised that there could be an issue with pre-1970 dates in Windows, and also did not know that we had to watch out for the 'centuryCutoff' property. Very, very useful to know. Peter's c

Re: Age & Anniversary Calculations

2012-05-21 Thread Peter M. Brigham, MD
Sorry, I copied and pasted an older version of the handler. Try this: function doAge tDate,asOf -- returns the age given birthdate = -- as of the date (if empty, assumes today) if tDate = empty then return empty if asOf = empty then put the date into asOf end if set the i

Re: Age & Anniversary Calculations

2012-05-21 Thread Bob Sneidar
Wasn't there a recent post that indicated this would not work? Anything before a certain date (I forget what it was) would be a day off? Bob On May 21, 2012, at 9:38 AM, Peter M. Brigham, MD wrote: > Here's what I use for #1: > > function doAge tDate,asOf > -- return the age given birthdate

Re: Age & Anniversary Calculations

2012-05-21 Thread Peter M. Brigham, MD
Here's what I use for #1: function doAge tDate,asOf -- return the age given birthdate = -- as of the date (if empty, assumes today) convert tDate to dateItems if asOf = empty then put the date into asOf end if convert asOf to dateitems put item 1 of asOf - item 1 of tD

Re: Age & Anniversary Calculations

2012-05-21 Thread André Bisseret
Bonjour Igor, Le 21 mai 2012 à 09:02, Igor de Oliveira Couto a écrit : > Dear LC Folks, > > What is the 'best' way to perform these 2 calculations with LiveCode? > > 1) Calculate a person's age, given a birthdate: I had problems with scripts mainly based on "convert to seconds" and "dateItems

Re: Age & Anniversary Calculations

2012-05-21 Thread Ken Corey
On 21/05/2012 08:02, Igor de Oliveira Couto wrote: What is the 'best' way to perform these 2 calculations with LiveCode? 'convert' just rocks. Here's a couple of throwaways to show you how I'd approach it. They probably aren't exactly what you need, but you'll get the idea. 1) Calculate

Age & Anniversary Calculations

2012-05-21 Thread Igor de Oliveira Couto
Dear LC Folks, What is the 'best' way to perform these 2 calculations with LiveCode? 1) Calculate a person's age, given a birthdate: /* Calculates the number of birthdays from a given date, up to and including *today*. @param pBirthDate the birthdate @return a positive integer represen