[SOLVED] Creating only month and year column in MySQL database

Issue

I’m creating a little program with Java. In the date field which is a ComboBox for selecting only month and date as 02/2016.

Is there a way to record this date format in MySQL in a mm/yy field only?

Solution

Instead of storing it in this format, maybe the best approach is to store it as a normal date with the day always set to the first day of the month.
And then at retrieval time you format the date, with something like a SimpleDateFormat, to only get the month and year and return it to your UI.

Answered By – P. Ekouaghe

Answer Checked By – Willingham (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *