|
|
Custom Search
| |
|
| |
|
Using MySQL Date and Time Functions, Part 1
MySQL Date and Time Functions are used to obtain or manipulate Date and Time data type values . Table below shows the default format of the zero value for date and time data.
Here are the links to Part 2 and 3:
Here is the list of MySQL Date and Time Functions for Part 1:
Practice #1: Using ADDDATE function. In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Adds 31 days to 2008-05-22
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /*
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add time to date and time value
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /* To use named time zones such as 'MET' or 'Europe/Moscow', the time zone tables must be properly set up in the system database mysql. Refer to article How to load time zone data for MySQL on Windows for more information.
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /*
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /*
Query result set - 1 row returned: For detailed information about timestamp, read this article How to use Date and Time data as integer value in PHP and MySQL. Practice #4-1: Using CURDATE function and return current date in YYYY-MM-DD formatIn Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /*
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /*
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /*
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /*
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 microsecond
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 second
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 12 minutes
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 3 hours
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 5 days
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 5 weeks
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 5 months
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 2 quarters
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 3 years
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 second and 123 microseconds
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 minute, 1 second, and 123 microseconds
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 minute and 15 seconds
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 hour, 1 minute, 1 second, and 123 microseconds
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 5 hours, 21 minutes, and 58 seconds
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 5 hours, 21 minutes
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 day, 1 hour, 1 minute, 1 second, and 123 microseconds
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 day, 2 hours, 5 minutes, and 27 seconds
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 day, 2 hours, and 5 minutes
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 day and 2 hours
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 year and 5 months
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /*
All four queries return the same result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Add 1 second by using + operator
Query result set - 1 row returned: In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- Minus 1 second by using - operator
Query result set - 1 row returned:
|
|
Copyright © 2010 GeeksEngine.com. All Rights Reserved. This website is hosted by LunarPages. No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it. |
| Home | Kung Fu Timer | Feedback | Terms of Use | Privacy Policy |