I have profiles with creation date column (DATETIME) in database. I need to implement search profiles by date in Java, which will return all profiles that were created on certain day or month.
What is the best way to implement this? I thought about adding new columns (day, month, year) and searching by them, but I don't know if this is the right way. Search shouldn't be slow and dates need to be localized.
Edit:
Yes, this query (from the other question) works:
SELECT * FROM profile WHERE DATE(creation_date) = '20190121';
What I see as a problem here is that this query will probably be slow in situation where there is a great number of profiles, because Date function must be performed first and than comparison on all creation dates. It seems to me that such solution is inefficient. I'm not sure if adding more columns (day, month and year as integers) will be a better solution, or maybe using indexing.