This is one of those questions that comes to you when you are responding to situations raised here on Stackoverflow.
Is there a possibility in MySQL to save a date and two different times in the same field?
That is, if I have this:
Fecha inicio: 2017-09-04
Hora inicio: 15:30:00
Hora fin : 18:30:00
Could you put all that in one field?
If it could be done, would it be feasible?
In a possible solution, I would avoid far-fetched solutions. My question refers to the possibility of a data type that allows this and that the stored data is what it is , that is, dates and/or times.
In MySQL there is no such thing as a "date range" data type, which is what you seem to be looking for. In the MySQL documentation you can find the data types and the specific types for date/time that are:
DATE
TIME
DATETIME
TIMESTAMP
YEAR
Which would all be unit values and not multiples (which is what you would need). In other database engines you could define your own type for what you're looking for, but MySQL doesn't have that functionality.
...although perhaps you could simulate it using a VARCHAR (although it would require you to apply functions on the field so it's not very natural or simple) or an object of type JSON ( available as of MySQL 5.7.8 ).
MySQL 5.7: The idea would be that you save a JSON with date, start time and end time, and then access the values to be able to operate on them (it would not be necessary to have special functions or cast values).
Here is an example ( you can run it here ):