Using a Generated Column to help with date lookups

I have a table that has two columns: year and month.
While its ok to search on exact dates or by year, it is harder to search between two dates.

Lets see if we can solve this issue by using a generated column.
(Table taken from


  1. If you used a proper date column like your supposed to you wouldnt have this problem.

  2. Indeed, but its nice to know that a bad table design can be fixed with a generated column or if an additional requirement was added later on.

  3. Ah! also, the original requirement was for a CSV file to fit for an Excel/Pivot Table analysis. Not a MySQL table.