Skip to content
Advertisement

Extracting data from only the year

I have data in a table in SQL with dates, but how do I select only those that happen in 2021. (The dates look like 31-oct-2020) in the table. The dates are the actual date variable, not just text.

Advertisement

Answer

You should avoid storing your dates as text, but rather should use a proper date column. That being said, you may check the right 4 characters of the date string:

If the column be an actual date type then use:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement