rondog Posted February 1, 2008 Share Posted February 1, 2008 I've never used field type 'date' since var char worked fine for me. I am running into a problem now. I am trying to sort by date and when I have information like below, the sort doesnt really work because its sorting alphabetically by date. What would the proper way of storing a date be so I can sort it? User Status Completed on ronnie_dop viewed Friday 01st of February 2008 10:06:36 AM JGoehring viewed Friday 01st of February 2008 10:13:16 AM JDiaz viewed Friday 21st of September 2007 01:47:48 PM MJackson viewed Friday 21st of September 2007 03:24:17 PM ALashbrook viewed Friday 21st of September 2007 03:45:06 PM datron099 viewed Monday 08th of October 2007 09:21:12 AM Datron101 viewed Monday 17th of September 2007 04:38:53 PM Datron100 viewed Sunday 02nd of September 2007 03:42:23 PM LCashin viewed Sunday 07th of October 2007 06:46:29 PM LBowman viewed Sunday 30th of September 2007 08:34:39 PM REllison viewed Thursday 04th of October 2007 03:37:11 PM ALePiere viewed Thursday 13th of September 2007 05:56:22 PM ABarter viewed Thursday 15th of November 2007 01:51:49 PM JCraft viewed Tuesday 25th of September 2007 07:29:44 PM Quote Link to comment https://forums.phpfreaks.com/topic/88929-solved-correct-way-of-putting-date-into-a-table/ Share on other sites More sharing options...
kenrbnsn Posted February 1, 2008 Share Posted February 1, 2008 You use a datetime field to store a date/time in the database. Then the sort will work. Ken Quote Link to comment https://forums.phpfreaks.com/topic/88929-solved-correct-way-of-putting-date-into-a-table/#findComment-455483 Share on other sites More sharing options...
rondog Posted February 1, 2008 Author Share Posted February 1, 2008 if I use the datetime field, how would my insert statement look..like what parameters would I being inserting? Quote Link to comment https://forums.phpfreaks.com/topic/88929-solved-correct-way-of-putting-date-into-a-table/#findComment-455491 Share on other sites More sharing options...
kenrbnsn Posted February 1, 2008 Share Posted February 1, 2008 What are you doing now? Ken Quote Link to comment https://forums.phpfreaks.com/topic/88929-solved-correct-way-of-putting-date-into-a-table/#findComment-455496 Share on other sites More sharing options...
revraz Posted February 1, 2008 Share Posted February 1, 2008 You would need to use YYYY-MM-DD HH:MM:SS format if I use the datetime field, how would my insert statement look..like what parameters would I being inserting? Quote Link to comment https://forums.phpfreaks.com/topic/88929-solved-correct-way-of-putting-date-into-a-table/#findComment-455504 Share on other sites More sharing options...
rondog Posted February 1, 2008 Author Share Posted February 1, 2008 awesome I think I got it from here..thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/88929-solved-correct-way-of-putting-date-into-a-table/#findComment-455523 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.