Date query : is this a working shortcut?

Hello everyone !

I’m currently working on the SQL course inside the Data Science Specialization. In a project, I stumbled into something that tickle my brain.

I’m asked to find all the users registered in a database born in the 80’s. The birth date is a TEXT data formatted like this ‘yyyy-mm-dd’ and the column is called birthday.

Given that the birthday is a TEXT, I figured the simplest way was to to use this query :

SELECT *
FROM users
WHERE birthday LIKE ‘198%’;

My thought on that would be that if the date of birth does not start with “198” the user is not born in the 80’s. The two answer given by Codecademy was to use the comparison operator and my solution is not included. So that leads me to my question : am I missing something there ?

I got no “wrong” results using my query and I figured that maybe I would miss some of the people born in the 80’s, but I don’t understand how this would happen. Anyone got a thought on that ?

Thank you for your help !

Hi @beta8158182664, welcome to the forums!

Can you please post a link to the exercise you are talking about? On first glance it seems like your query would be perfectly valid in this case, but I’d like to test it out with the actual data.

Thanks!

Hi ! Thank you for your answer !

I’m talking about this exercise and the it is the second task :

https://www.codecademy.com/paths/data-science/tracks/sql-basics/modules/dspath-sql-projects-and-applications/projects/user-segmentation-prj

After asking my question I ran a query counting the number of results for both my query and Codecademy one, both having the same result (348 if my memory does not fail me).

Thanks again !

Hello @beta8158182664, as @el_cocodrilo said, your code is not wrong, and is a short cut. The possibility is that the project wanted people to use comparison operators, or to demonstrate some aspect about comparison operators.