Age & Anniversary Calculations

Peter Haworth pete at lcsql.com
Wed May 23 12:17:19 EDT 2012


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 anniversary date, 2012-05-23 as the
target date, and 259200 as the4 seconds (=3 days):

SELECT (date('2012-05-23','+ 259200 seconds') >= date('2012-05-30'))

Note that this returns 1 or zero rather than true or false.  Also, you can
use days, hours, minutes, months as the interval rather than seconds, e.g.:

SELECT (date('2012-05-23','+ 3 days') >= date('2012-05-30'))

You can find complete description of all the sqlite date expressions at
http://www.sqlite.org/lang_datefunc.html

Hope that helps.

Pete
lcSQL Software <http://www.lcsql.com>



On Tue, May 22, 2012 at 10:56 PM, Igor de Oliveira Couto <
igor at superstudent.net> wrote:

> 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 find
> this post from you. Would you mind sending it again? - I would really like
> to see your suggestion!
>
> Many thanks in advance,
>
> --
> Igor Couto
> Sydney, Australia
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list