Firstly, itβs bad practice to keep the date and time in different fields.
In any case, if you save the date / time in the appropriate format. (i.e., the date format is yyyy-mm-dd, and the time is hh: ss)
First you need to combine the date and time to get the datetime value. From a technical point of view, you can do ORDER BY ON in the Datetime field, but this is not a good practice. In our case, when we run CONCAT, this is converted to a string, so the result will be incorrect. Therefore, you need to convert it to UNIX TIMESTAMP in order to place an order.
It is good practice to run UNIX_TIMESTAMP in the datetime field before the ORDER by clause.
You can use the following query.
SELECT column1, column2, UNIX_TIMESTAMP (CONCAT ( event_date , '', event_time )) as unixtimestamp from_name_name Order by unixtimestamp desc;
Note. (The CONCAT function has a space between event_date and event_time. It does not display correctly here.)
irshad
source share