gevo12321 Posted June 22, 2007 Share Posted June 22, 2007 hi lets say im making an archive database in mysql each article has a date how do i need to imput the date in mysql in 3 different columns(day, month, year) or just one column if later i want to have the articles be in chronological order when i look at them on my website? which is more efficient and easy? what do u recommend? and is there some code for putting the articles in chronological order? thank you Quote Link to comment https://forums.phpfreaks.com/topic/56755-solved-mysql-dates/ Share on other sites More sharing options...
cooldude832 Posted June 22, 2007 Share Posted June 22, 2007 no the mysql date column is best to use because any way you deal with a date it will be testing in a format YYYY/MM/DD which is the format you put in. To order just when you run a query use the line ORDER BY `Datefield` at the end of it (past the WHERE part). You can search for stuff in your table that was say last month by using the mkdate() function. its pretty simple to use and it will be way easier than testing 3 columns, plus as an optimization its always best to reduce number of fields Quote Link to comment https://forums.phpfreaks.com/topic/56755-solved-mysql-dates/#findComment-280273 Share on other sites More sharing options...
chigley Posted June 22, 2007 Share Posted June 22, 2007 Personally I prefer the use of timestamps over the MySQL standard of YYYY/MM/DD. Timestamps can be outputted however you like with PHP, and you can output them in order too. The MySQL version is easier to calculate differences etc. It's all down to personal preference really... Quote Link to comment https://forums.phpfreaks.com/topic/56755-solved-mysql-dates/#findComment-280276 Share on other sites More sharing options...
cooldude832 Posted June 22, 2007 Share Posted June 22, 2007 its up to you how you do it but 99% of the time you are going to reformat days any way, I actually take the 2007/05/01 and change it to May 1st, 2007 so really I don't care what its like in the table as long as its got a year, month, day Quote Link to comment https://forums.phpfreaks.com/topic/56755-solved-mysql-dates/#findComment-280280 Share on other sites More sharing options...
gevo12321 Posted June 22, 2007 Author Share Posted June 22, 2007 thank you very much for the advice Quote Link to comment https://forums.phpfreaks.com/topic/56755-solved-mysql-dates/#findComment-280287 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.