Jump to content

int, and the disappearing 0


msaf101

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

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.