Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
Thread: new to using MySQL
06-29-2011, 05:53 PM #1
- Join Date
- Jun 2010
- Thanked 0 Times in 0 Posts
new to using MySQL
I'm new to using MySQL and I'm having some issues creating a simple database for uploading a basic app. Can anybody help me with the format to use in the MySQL Command?
My other question is..What is the best (most efficient) way to push the date/time into MySQL so that it saves properly, and to pull is back out of MySQL and render it on the screen in the reverse format? Thanks!
Last edited by oracleguy; 06-29-2011 at 07:47 PM. Reason: signature rule violation
06-29-2011, 06:02 PM #2
- Join Date
- Jun 2011
- Thanked 3 Times in 3 Posts
Last edited by oracleguy; 06-29-2011 at 07:47 PM. Reason: removed signaure from quoted post
06-29-2011, 09:22 PM #3
What do you mean by "MySQL Command"??
You mean the MySQL command-line environment? Where you just get a mysql> prompt and then type in commands?
Or do you mean some other environment?
06-29-2011, 09:26 PM #4
As for dates and times: No easy answer. The only way MySQL undestands a *literal* date and time is in the form 'yyyy/mm/dd hh:mm:ss'. So '2011/6/27 15:22:00' would be valid.
When retrieving dates, you *can* ask MySQL to convert the internal form to a string for you, but more often than not you are better off doing that in the host language (e.g., PHP or ASP or JSP) instead.
On note: If you want to insert the date and time of *right now* into the table, then just use MySQL's built-in functions.
Code:INSERT INTO sometable( aDateTime, aDateOnly, aTimeOnly ) VALUES( NOW(), CURDATE(), TIME(NOW()) )