Tim Habersack

Page 19 of 20

Date-storing tests in MySQL; Part 1

Data, what fun it is!

My issue is this, I’m working on a web app, which uses CodeIgniter, with a MySQL DB. My question was, since all I am storing for a date time is the year, month and day, what is the best way to do this? I’m going to be making a lot of queries like “select all entries from user bob from March to May of this year”.

As I see it, there are several options:

  1. Use the DATE data type in MySQL, which stores as “YYYY-MM-DD”.
  2. Generate 3 attributes, each an integer, one “year”, one “month”, and one “day”.
  3. My new idea, to store it as an integer, in a “YYYYMMDD” format. It will allow for decent queries, since the hierarchy of time still works. (May still comes before March, 20110301 < 20110501).
  4. Use the time function in php, which returns the number of seconds since 1970. A lot of people go this route, but I think it’s crap because in 2038 it will restart, causing issues . Y2K38 people! I’m going to pretend you didn’t even bring this up.

I’m writing a script that will generate about 10.000.000 rows of data, each with every date recording option I mentioned above, then I will make some pretty bar graphs and we shall see what we shall see.

My guestimate is that my integer idea (“YYYYMMDD”) will be the fastest, but let’s see.

Maybe I don’t need to rush into the Cloud

The Cloud is everywhere it seems. And this is okay. There are times where it is so useful! For example, I love Rackspace.

Recently though, I’ve been thinking about where everything is going, how everything “needs” to be in the cloud. Specifically, music and files. The problem is, these services are not guarantees, so to “be safe” a user would want to have there data in several places. Have pictures on Flickr? Use the API to mirror it to a privately hosted site. Data? Better schedule to pull it down occasionally in case of an issue with the company.

Then, I had an “ah ha!” moment. The cloud is great, but if you want access to files,pictures, music, etc everywhere, isn’t it easier to use a USB flash drive? I realize it isn’t the new hotness, but it kind of does the job pretty well. I’m not saying the Cloud doesn’t have it’s uses. But maybe remember the modest USB flash drive, and what it can do.

Network connectivity issues, a baby, and books

I have spent all day at work troubleshooting a network issue on my machine. Finally have it working, though my method of fixing it isn’t exactly the best.

So frustrating to lose an entire day to a problem like this.

And tomorrow, a large portion of my day will be spent moving to a new cubicle. Doh! Well, maybe next week I can get some things done here at work.

Regarding personal projects, they are at a standstill at a moment. The arrival of our little boy A has been wonderful. It also requires a lot of work! It’s a delight to be with him, and watch him observe more of the world around him. The pooey diapers are just a bonus.

I have been doing a little reading. I finally got around to reading “I, Robot” by Isaac Asminov, and I enjoyed it. Encourages me to work on my short stories, since that is mostly what that book is comprised of. Just because it’s short doesn’t mean it isn’t worth doing!

Now I started “Atlas Shrugged” by Ayn Rand. About 60 pages in, and it’s making me want to play Transport Tycoon. Also, there are portions of her philosophy that I can agree with.


Pale banners held high,
shining Lancers bravely charge,
Towards the fearsome horde.


Problems from the past,
do relentlessly whisper,
Useless solutions.

« Older posts Newer posts »

Copyright © 2018 Tim Habersack

Theme by Anders NorenUp ↑