I need to select a max(date) from a MySQL table and have each part of the date and time be in a separate variable.
Something like:
select max(date) as year, month, day, hour, minute, second from table
How would I do that?
You can do this way:
SELECT
YEAR ( MAX(date) ) as year,
MONTH ( MAX(date) ) as month,
DAY ( MAX(date) ) as day,
HOUR( MAX(date) ) as hour,
MINUTE( MAX(date) ) as minute,
SECOND( MAX(date) ) as second
from table