SQLite query to return records earlier than a certain year? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

SQLite query to return records earlier than a certain year?

I am trying to come up with an SQL query to return all the records earlier than a certain year with SQLite using DB Browser. I can't seem to come up with the right regex expression to use for filtering only the year from a row for comparison, below is the query am using. It is returning 0 records please help. SELECT * FROM EMPLOYEES WHERE strftime('%Y', HireDate)<2003; I am trying to get all records where the HireDate which is a column is earler than 2003, please help.

20th Apr 2022, 2:23 PM
Timothy Njiru
Timothy Njiru - avatar
3 Réponses
+ 1
SELECT * FROM EMPLOYEES WHERE DATE_FORMAT('%Y',HireDate)<2003
22nd Apr 2022, 5:42 PM
Václav Dostál
Václav Dostál - avatar
+ 1
Thanks Vaclav but I already got the answer, I used cast as integer and it worked
23rd Apr 2022, 6:17 AM
Timothy Njiru
Timothy Njiru - avatar
0
👍
23rd Apr 2022, 6:18 AM
Václav Dostál
Václav Dostál - avatar