Sven Aluoor <alu...@gmail.com> wrote: > I have a table with name, date in format DD.MM.YYYY.
If at all possible, switch to one of the formats that SQLite date functions understand, e.g. YYYY-MM-DD - see http://www.sqlite.org/lang_datefunc.html . This format has the advantage that a simple string comparison happens to order dates correctly. > name expiry date > example CA 04.05.2013 > example Sub-CA 01.09.2012 > > I need to something like this (I try to explain in pseudo code) > > if SYSDATE (current date) minus 6 months > $expiry date > print OK > else print NOK with $name and $expiry date > > I know this is possible with Oracle. How to do this in sqlite? Assuming you've switched to the recommended date format, it would be something like this: select (case when date('now', '-6 months') > expiry then 'OK' else 'NOK' end), name, expiry from MyTable; If you insist on keeping your existing format, you can do this: select (case when date('now', '-6 months') > (substr(expiry, 7) || '-' || substr(expiry, 4, 2) || '-' || substr(expiry, 1, 2)) then 'OK' else 'NOK' end), name, expiry from MyTable; -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users