I have a column in my mySQL database that stores dates in a comma separated list. Because of the need and dynamic structure of this database it needs to be a comma separated list with this format:
date,date,date,date,date,date,date,date
A real set may look like this:
2012-01-01,2012-03-12,,,,,,
I need to be able to count the number of dates in this list in my query. For the example set above the number of dates in the set would be two (2012-01-01 & 2012-03-12). For my purposes I need to know if there are 8 dates in this list or not. I have found different solutions around and I had success with something like this giving me the number of time the number 1 was in a string:
LENGTH(_COLUMN_) - LENGTH(REPLACE(_COLUMN_, '1', ''))
If I changed the '1' to a regex then I couldn't get it to work. Part of the problem is I also could not find a solution for a regex that would find exactly ####/##/## and not any other variations of a date.
I am still learning mySQL and regex and am looking for some help.
THANKS.