I need to get current date (and time 00:00:00) epoch timestamp in MySQL request. I want to do this with math expression: (UNIX_TIMESTAMP() - (UNIX_TIMESTAMP() % 86400)).
But this calls UNIX_TIMESTAMP() more than once; so the question is - is there a possibility that two UNIX_TIMESTAMP() functions return different time? What is the workaround in this case?
Or maybe MySQL executes UNIX_TIMESTAMP() once, and replaces all other calls with current timestamp and no workaround needed?
Paul Dixon :
You could use UNIX_TIMESTAMP(NOW()), because NOW() returns the timestamp when the statement began to execute, so it would behave consistently across multiple calls in the same statement.\n\n\n NOW() returns a constant time that indicates the time at which the\n statement began to execute. (Within a stored function or trigger,\n NOW() returns the time at which the function or triggering statement\n began to execute.)\n",
2015-03-07T14:30:52
i486 :
SELECT @ut:=UNIX_TIMESTAMP(), (@ut - (@ut % 86400)) AS ep;\n",
2015-03-07T14:24:44