jeofjingjeff
06-29-2011, 04:53 PM
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!
TrevorWeaver
06-29-2011, 05:02 PM
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!
Possibly I can help you if I know what you want to do precisely.
And I am sure there are many of the more expert guys on this site willing to assist. I have found people on this site to extremely helpful.
Regards Trevor
Old Pedant
06-29-2011, 08:22 PM
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?
Old Pedant
06-29-2011, 08:26 PM
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.
Examples:
INSERT INTO sometable( aDateTime, aDateOnly, aTimeOnly ) VALUES( NOW(), CURDATE(), TIME(NOW()) )