|
Title: Proper way to handle and store DATE in mysql Post by: thepreacher on April 13, 2007, 03:01:09 PM Say l have a date say 13 April 2007 (UK style). for the Month the actual value i am storing becomes 4 so the date is 13 4 2007. I rearrange it to yearmonthday format as that is how mysql stores dates. This date now becomes 2007413. When i store it, mysql stores it as 200-74-13. What is the right way to do this seeing that mysql uses 0000-00-00.
Secondly in the situation where i only need to store the month and year, ie 0000-00, how do i do this so that mysql will do the right thing. I use PHP BTW. Title: Re: Proper way to handle and store DATE in mysql Post by: VGR on April 15, 2007, 12:50:19 AM 1) you forgot the leading zero for the month. Use a dat() format that pads zeroes to the left (I always use Y-m-d H:i:s)
2) just store your data appended with "-01" (a fake day) and ignore it when retrieving data
Powered by SMF 1.1 RC2 |
SMF © 2001-2005, Lewis Media
Joomla Bridge by JoomlaHacks.com |