This is my first post so go easy on me! I'm teaching myself SQLite 3 and entering all commands in "Terminal". I'm using Sams Teach Yourself SQL in 10 Minutes which covers SQL in general but not SQLite. I'm extracting a date from a database and using the following syntax:
sqlite> SELECT order_num FROM Orders WHERE order_date BETWEEN date('2004-01-01') AND date('2004-12-31');
The object is to extract "All Orders" from the year "2004", this produces the correct results as expected, however I'd like a cleaner form such as:
sqlite> SELECT order_num FROM Orders WHERE date(YYYY, order_date) = 2004;
This doesn't work! I know the form is:
date(timestring, modifier, modifier, ...) however I can't get it right. Your help is appreciated.
John
sqlite> SELECT order_num FROM Orders WHERE order_date BETWEEN date('2004-01-01') AND date('2004-12-31');
The object is to extract "All Orders" from the year "2004", this produces the correct results as expected, however I'd like a cleaner form such as:
sqlite> SELECT order_num FROM Orders WHERE date(YYYY, order_date) = 2004;
This doesn't work! I know the form is:
date(timestring, modifier, modifier, ...) however I can't get it right. Your help is appreciated.
John