1 | 2 | 3 | 4 | 5

6 - 10   [23]

MySQL Date Datatypes

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 […].

  • Timestamp can be a useful tool for write once data where a log time is required. The field can be excluded from a MySQL DML UPDATE statement, and will be autocompleted as the statement is executed.
  • Where a schema definition has both an added and amended field, placing the amended field first will ensure it is automatically updated each time a DML statement is executed. However, when the data is first entered, the added field must be set specifically using NOW() or a NULL value.
  • A Timestamp value can also be explicitly set in an INSERT or UPDATE statement.
  • For a schema with a predefined date range of historical significance, the Date or DateTime datatype is a more reliable choice - see this comment on Simon's blog.
  • A Date datatype is clearly a better choice for a fixed date, eg an appointment or anniversary.

Posted on Jul 13, 2003 at 23:54:59. [Comments for MySQL Date Datatypes- 2]

Gangs Of New York

Relates to Movies

Wow, just watched Gangs of New York and what a film it is! Phenomenal cinematography and atmosphere in a really brutal world of meat cleavers and razor blades. I have always been a huge fan of DDL from innumerable viewings of Last of the Mohicans, but he really shows depth and character in this film. Just hope it isn't another 5 or so years before we see him again….

Posted on Jul 13, 2003 at 04:45:17. [Comments for Gangs Of New York- 2]

Comments Form Added

Relates to Blogging

A comments submission form has now been added to this Blog. Still in it's rough, hewn stage, so apologies if it bugs out on anyone. Initial tests have run ok. The form accepts inline XHTML 1.0 elements from %phrase; and %special;, along with blockquote, address and p. That is most of the common markup used on paragraph content (eg code, em, strong, abbr, acronym). If you use markup in a comment, please ensure it is well formed. A simple parser will test for errors in well-formedness, and invalid nesting.

Posted on Jul 13, 2003 at 01:09:31. [Comments for Comments Form Added- 0]

Personal Aggreg8or

Relates to Blogging

Before I even got round to building this blog, I actually started out building an aggregator using PHP to parse RSS news feeds. This is a simple interface with an iframe (to comply with XHTML Strict) containing a separate document parsed as XHTML showing the news feed. It has some of the blogs I spend most time reading, so I can quickly switch between them and keep track of the latest news and gossip.

Posted on Jul 11, 2003 at 04:37:39. [Comments for Personal Aggreg8or- 0]

Fresh Look To Blog

Relates to CSS Design and Blogging

Since the logs seem to be showing a few visits to this blog, I decided to throw in a bit of style as it was all looking a bit plain. Kept things simple, clear and accessible, but in a hurry I nearly ran into a wall, when I failed to account for the content pane being less than the size of the screen window. Once again DOM came to the rescue in browser Standards Modes, with a simple script to retrieve the height of the window pane and individual div containers:

document.getElementById("id").offsetHeight (for the height of a container)

document.getElementById("id").offsetTop (to get the top pixel position of a container)

Then the container can be resized on the fly as the page loads, or window is resized. The DOM inspector in Mozilla is excellent for working with all the DOM properties and testing scripts that manipulate the document tree quickly and accurately. Don't know how I got by without it now!

I also wanted to apply fixed positioning to the menu, so this property is also added on page load following a browser detection script, since div {position:fixed} does not place the container in the right place in IE - where absolute positioning is assigned instead.

Posted on Jul 11, 2003 at 03:13:56. [Comments for Fresh Look To Blog- 0]

Breadcrumbs Trail

[ Home ] -> TW Blog -> Archives for July 2003
Site Map

The Severn Solutions website achieves the following standards:

[ XHTML 1.0 ] [ CSS 2 ] [ WAI AA ] [ Bobby AA ]

Page compiled in 0.013 seconds