Jump to content


Photo

int, and the disappearing 0


  • Please log in to reply
2 replies to this topic

#1 msaf101

msaf101
  • Members
  • Pip
  • Newbie
  • 1 posts

Posted 27 December 2003 - 05:45 AM

....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

#2 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,664 posts
  • LocationLos Angeles, CA USA

Posted 27 December 2003 - 07:38 AM

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.

#3 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,664 posts
  • LocationLos Angeles, CA USA

Posted 27 December 2003 - 08:05 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users