PHP and MySQL syntax: Difference between revisions

Jump to navigation Jump to search
Line 156: Line 156:
* Use [http://www.w3schools.com/sql/func_date.asp MySQL DATE() Function]: {{kbd | key = <nowiki>DATE( time )</nowiki>}}
* Use [http://www.w3schools.com/sql/func_date.asp MySQL DATE() Function]: {{kbd | key = <nowiki>DATE( time )</nowiki>}}
* Use [http://www.w3schools.com/sql/func_date_format.asp MySQL DATE_FORMAT() Function]: {{kbd | key = <nowiki>DATE_FORMAT( time, '%Y-%m-%d')</nowiki>}}
* Use [http://www.w3schools.com/sql/func_date_format.asp MySQL DATE_FORMAT() Function]: {{kbd | key = <nowiki>DATE_FORMAT( time, '%Y-%m-%d')</nowiki>}}
=== timer ===
Recording the time elapsed after the sql query was executed.
<pre>
SELECT @timer := CURRENT_TIMESTAMP();
SELECT SLEEP(2); //sleep 2 seconds for testing purpose
SELECT 'custom message' AS 'action', CURRENT_TIMESTAMP() AS 'end time', @timer AS 'start time', TIMEDIFF(CURRENT_TIMESTAMP(), @timer) AS 'time elapsed';
</pre>


=== further reading ===
=== further reading ===

Navigation menu