Filed under: Uncategorized
Tags: Scripts
I just got an email from docs@mysql.com saying the following:
The user comment system in the MySQL manual is not the place to request features. You can do so using our bug-tracking system at http://bugs.mysql.com/. Thanks. (Actually, your comment is not a feature request, but it relates to another comment that is. The example you’re giving is nice, but this is a reference manual, so we have to restrict it to _a few_ useful examples.)
My original comment was:
You bring up some important issues, but dealing with ages really isn’t that hard. For example you could do something like this:
mysql> SELECT DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(dob)), '%Y')+0 AS age FROM people;
Where ‘dob’ is obviously their date of birth. It’ll also work with pre and post-epoch dates. Please excuse the funky formatting as the
comment stem seems to insist on inserting line breaks into the code block. I ran into this problem while working on some genealogical things over at Mullenweg.com, a family site. I hope this helps!
Looking back, it’s funny that the comment is still around, I wrote it over two years ago. The date and time functions is the MySQL page I use most, so in some sense it was always nice to have my mark on there. For google and posterity I’ve preserved the comment here.
I’m glad they’re cleaning up the comments, as they are really bad in places and have atrocious formatting, especially when compared to say, the PHP manual. However there is a later comment (which is still up) that offers perhaps a better method. From Kirill Novitchenko:
The method posted by Mathew Mullenweg is good, but leap years goof it up on birthdays. (Try it. Use the current date and subtract exactly 5 years ago.)
Hopefully this will be the last ‘find age’ function. There is a simple premise to it:
- Subtract the current year from the birth year to get the age.
- If the current month and date is less than the birth month and date, subtract 1 from step 1.
Therefore, this should work with everyone who wasn’t born in the future.
SELECT DATE_FORMAT(NOW(), '%Y') - DATE_FORMAT(dob, '%Y') - (DATE_FORMAT(NOW(), '00-%m-%d') < DATE_FORMAT(dob, '00-%m-%d')) AS age
where dob is date of birth.
I’ve never run into any problems with my function but I see nothing wrong with the way this one works, so I may update my code to use it.
Why not just use unix timestamps and avoid all the funkiness? When I first started writing everything I actually did, but then one day I got a call from my lovely sister saying that it was showing everyone’s birthday as January 8th, 1901 (or something like that). I had reached the negative limit of a 32-bit integer, the upper limit being sometime in 2038. Moving all the date functions into the SQL is probably bad from a programming point of view but it works great for the application. Of course I have no clue how it deals with the 10 days Pope Gregory removed from the calendar in 1582. Hopefully that won’t come up.
Filed under: email
Tags: Reviews
As you may have heard, Thunderbird 0.4 has been released, and it’s a delight. I’ve been using Thunderbird off and on since I first heard of the project. I snubbed 0.2, as it was quite clunky. 0.3 changed my mind and became my default email client over Outlook Express, and I also set it up for my mom. However it was not so much on Thunderbird’s merits of the time that I switched, because it was still quite rough in many areas, it was simply the least bad of all the IMAP email clients I have tried. (And I’ve tried them all.) However this new 0.4 version is a pleasure to use. The graphics have been completely revamped, which is a much bigger deal than I would have thought and really changes how I view the application. (Literally.) Of course they were pretty patchy before, it didn’t even have a separate icon for mail you had replied to. The other problem I had before was that the program would get hung up on something, I’m not sure what, but when it was nothing would work until I restarted the application, which was annoying to say the least. I haven’t even seen a hint of this problem for about two months now (I’ve been keeping up with the weekly builds).
It just does IMAP so well. Having all my email and folders on the server makes it easy to try different email clients and not worry about importing, exporting, or keeping my data in sync. A few minutes ago, just to make sure I wasn’t remembering things wrong, I opened up Outlook Express again to give it another go. That’ll probably be the last time I ever do. Moving IMAP messages to different folders in Outlook Express opens a dialog box that actually precludes you from doing anything else in the application, so if you’re moving a message with a large attachment or several messages you have to wait for everything to finish before you can do anything else. For someone who lives in their email client, that is simply unacceptable. Thunderbird does all that in the background, and it’s so fast with most things that the “IMAP lag” is gone.
It’s not perfect, there are a few things I hope the Thunderbird team addresses in future releases. First is the spell check, which rocks but always wants to spell check the name of the person I’m replying to in an email. Second when I forward a message inline it includes all the headers, which can often be twenty or thirty lines, most of it junk that isn’t important. Just give me from, to, subject, and when it was sent, and I’ll be happy.
Thunderbird understands that on some IMAP servers, including mine, some folders contain mail messages and some just contain other folders. Outlook Express would try to select these “holding” folders and return an error, where Thunderbird shows them in italics so they’re visually set apart from the folders that hold actual mail. Thunderbird is also supposed to have some great spam handling, but since I handle all that on the server side I can’t speak to that personally.
Bottom line: try it out. You have nothing to lose and you might just find that perfect email application you’ve been searching for. The best thing about it is I know that right now another version is in the works, and in a few months they’ll be a 0.5 I can rave about. Or I could wait until 2006 for a new version of OE to come out with Longhorn. Right.