SkyKnight
SkyKnight

Reputation: 13

mysql select contain range of information

I'm working on a project dealing with the IMDB database. I've searched around but haven't come across anything that would help.

I need to filter out movies before 31 December 1983.

However the table structure is set up with the release_date column being VARCHAR and the values are something like: USA:31 December 1983.

movie_id         release_date
283192           USA:31 December 1983

EDIT: I was looking through some of the records and some of the dates only include the year.

Does anyone have an idea on how to accomplish this? Or somewhere to look?

Thank you.

Upvotes: 1

Views: 41

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270793

You can convert it to a date using str_to_date(), but you need to get the part after the :, so:

select str_to_date(substring_index(release_date, ':', -1), '%d %M %Y')

Upvotes: 3

Related Questions