I built a Mac OS app to read a SQLITE database. My select statement is fairly simple and works OK, giving me a good RecordSet. Now, I want to add to the select statement to look at a string/text column containing a date field looking like this: yyyy-mm-dd. What I need to do in the select is to return only those records with “2025” in the first four bytes. I tried the .left(4) thing appended to the column name but the compiler isn’t happy with that.
Is there a way to do this in the SQL select, or do I have to mess with that field in the rest of my code, bypassing all those records NOT in 2025?
Well, it turns out that the compiler doesn’t squawk, but I get a Database Exception about my left parenthesis. Here is the select statement:
App.rs = App.db.SelectSQL(“SELECT * FROM TABLE_HRD_CONTACTS_V07 WHERE COL_OPERATOR =? and COL_MY_GRIDSQUARE =? and COL_BAND =? and COL_QSO_DATE.left(4) =? and (COL_DXCC =291 or COL_DXCC = 6 OR COL_DXCC = 110)”, Globals.gblMyCall, Globals.gblMyGridSquare, TheBand, TheYear)
The problem is with the COL_QSO_DATE.Left(4) part. Removing that results in a normal rowset being returned. I just need to only have records from 2025. And, the string variable “TheYear” is set to a value of “2025”.