Yet nature cannot be contravened, but preserves a fixed and immutable orderBenedict Spinoza
Relates to MySQL and Databases
Here is a good tutorial on Date Arithmetic with MySQL. It demonstrates a small part of the depth of the Date API in MySQL which can dramtically cut down on uneccessary user defined date functions in PHP and the like. Simon Willison has also written a brief follow up to this on Storing Dates in MySQL and the MySQL Unix conversion functions, which allow a DateTime datatype to be readily converted to the native Unix timestamp format for PHP processing.
This has got me thinking briefly about the best choice for MySQL storage between Timestamp and DateTime. For this blog, I have used the Timestamp datatype in my schemas for all date fields. Both datatypes have access to the full set of date manipulation functions in the MySQL API, and there is no difference in memory use. So, example, for the dates on this blog I have the following call as part of a MySQL SELECT statements:
SELECT […] DATE_FORMAT(added, '%e %M %Y - %T') as create_time FROM […].
Posted on Sunday, Jul 13, 2003 at 22:54:59.
Comments on MySQL Date Datatypes (2)
α comment
I have a query.If one has to get the date wise entries from a table where the field has datatype as 'datetime' how to get it? Suppose there is a table which stores the information of daily blogs.Can he/she get the entries datewise?& how?
Posted by Chamboo Gabale
Friday, Nov 11, 2005 at 12:47:47
β comment
Not entirely sure what you mean! Do you mean select the records in date order (most recent post first):
or grouped on specific dates: Use PEAR::DB API.
Does that answer your question, or are you asking something different?
Posted by Tom
Friday, Nov 11, 2005 at 14:58:43