Filter records according to year.

If you have a field which having year in it then you can filter that table using year in a simple one line of query. It will help you if you are a backend or data science guy then while working on huge data in SQL.

Just you need to use format like below

  • to get distinct years and data from the table : SELECT DISTINCT YEAR(date_column) FROM your_table;
  • to get specific years records you may use SELECT * FROM your_table WHERE YEAR(date_column) = '2024';

I am surprise when use it in my recent project. Try it once and 100% sure you will get cool vibe when you use it. Like a pro 😎. After using these two lines of query I get a complete faith that from the database you can solve 70% of issues you face in real time while displaying data.

Conclusion

Correct your coding and programming skills to achieve more.