This 'hard-coded' SQL does the job:

select
(date('now') - '2002-12-23') -
((julianday('now', '-4year') < julianday('2002-12-23')))

But the trouble is to get the value 4 here.
This value should be date('now') - '2002-12-23'
But I can't get the right syntax to achieve that.

RBS


-----Original Message-----
From: RB Smissaert [mailto:[EMAIL PROTECTED] 
Sent: 22 December 2006 17:03
To: sqlite-users@sqlite.org
Subject: [sqlite] calculate age

Is there a way to calculate the age given the 2 dates in the standard format
yyyy-mm-dd? I could do julianday('now') - julianday(dateofbirth) and divide
by 365, but that won't be accurate enough.
It would be easy to calculate the age in the application and update the
database, but I prefer to do it all in SQL if I can.

RBS



----------------------------------------------------------------------------
-
To unsubscribe, send email to [EMAIL PROTECTED]
----------------------------------------------------------------------------
-




-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to