Sorry, forget about this, it was something in the VBA code, so nil to do with SQLite.
Could I ask you how I would get the age in months? I can see it will be along similar lines, but maybe you have worked it out already. I need it to be full calendar months, so, if current date is 2007-05-31 then DOB Age in months -------------------------- 2007-05-01 0 2007-04-30 1 2007-01-01 4 Etc. RBS -----Original Message----- From: Dennis Cote [mailto:[EMAIL PROTECTED] Sent: 31 May 2007 22:17 To: sqlite-users@sqlite.org Subject: Re: [sqlite] Age calculation on literal RB Smissaert wrote: > Thanks to Dennis Cote I got a nice way to get the age from the date in the > form 'yyyy-nmm-dd'. It works fine when I run it on a field, but when I run > it on a literal date it gives me 100 too much: > > select > case when > date('2002-01-01', '+' || (strftime('%Y', 'now') - > strftime('%Y', '2002-01-01')) || ' years') <= date('now') > then > strftime('%Y', 'now') - strftime('%Y', '2002-01-01') > else > strftime('%Y', 'now') - strftime('%Y', '2002-01-01') - 1 > end > > Why is this? > > This works for me in the sqlite shell as shown below: C:\Documents and Settings\DennisC>sqlite3 SQLite version 3.3.15 Enter ".help" for instructions sqlite> sqlite> select ...> case when ...> date('2002-01-01', '+' || (strftime('%Y', 'now') - ...> strftime('%Y', '2002-01-01')) || ' years') <= date('now') ...> then ...> strftime('%Y', 'now') - strftime('%Y', '2002-01-01') ...> else ...> strftime('%Y', 'now') - strftime('%Y', '2002-01-01') - 1 ...> end ...> ; 5 How are you running this query? Dennis Cote ---------------------------------------------------------------------------- - To unsubscribe, send email to [EMAIL PROTECTED] ---------------------------------------------------------------------------- - ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------