Jump to content

Archived

This topic is now archived and is closed to further replies.

msaf101

int, and the disappearing 0

Recommended Posts

....which column type allows for a whole number that begins with a zero? I\'m storing dates in three parts, month day year, and the year (03 in this case) is being truncated because of the zero. I\'d rather store these in three seperate columns rather than one date-type column.. Is there a column type for this?

 

er, I\'m sure this is documented in the manual, but I just don\'t know what to look for. I\'ll keep searching tonight, but your help would be appreciated.

Caleb

Share this post


Link to post
Share on other sites

The storage and presentation are two different things in sql. You can display a number any way you want using the format() function.

 

I think that not using a date or datetime column is a very very bad idea... you say you want to, but not the reason why.

 

Nevertheless if you feel you must fight against the features the database gives you, it sounds as if any mysql integer type will work fine for you. In this case the smallest one will work (two digit day/month/year) so a tinyint sounds right.

Share this post


Link to post
Share on other sites

Well I\'m gonna eat my words on this one a bit... mysql kinda sucks in numeric presentation. Again if you really want to do this apparently you need to specify a width attribute for the column (in your case 2) with the zerofill attribute. When you do selects, the numbers will come out with leading zeros. Again, none of this necessary if you just use a Date, which gives you the great date formatting.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.