msaf101 Posted December 27, 2003 Share Posted December 27, 2003 ....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 Quote Link to comment https://forums.phpfreaks.com/topic/1560-int-and-the-disappearing-0/ Share on other sites More sharing options...
gizmola Posted December 27, 2003 Share Posted December 27, 2003 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. Quote Link to comment https://forums.phpfreaks.com/topic/1560-int-and-the-disappearing-0/#findComment-5117 Share on other sites More sharing options...
gizmola Posted December 27, 2003 Share Posted December 27, 2003 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. Quote Link to comment https://forums.phpfreaks.com/topic/1560-int-and-the-disappearing-0/#findComment-5120 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.