I have a DB table with relation 1: N where N
represents multiple dates for one event. The column with the dates is DateTime
type, and I would like to keep the Time
option for later use, but it won't be so bad if I have to change it to Date
type.
The problem comes when I have to show those multiple dates in some GUI
. I get the dates with the GROUP_CONCAT
function which means that in JavaScript I operate with a string with comma-separated values representing the different dates, which by now is in the default SQL DateTime
format - YYYY-mm-dd hh:mm:ss
.
I use the split(',')
function to get each date-time value and what I can do is to change the type of the SQL column to Date
so when I split the string in JavaScript to end up with YYYY-mm-dd
values. Which should be reversed to dd-mm-YYYY
for the GUI
.
I'm not sure how to proceed here. I have in mind two main options:
First: Maybe there's a way to use dd-mm-YYYY
format in SQL which will solve all the problems.
Second: some kind of (complex?!?) String manipulation in JavaScript to split the string of dates into an array with multiple elements and then try to format each element the way I need.
Honestly - I want to avoid the second option, but don't know if the first is possible, and maybe, there's another way that I haven't think of.