lmhart Posted November 3, 2009 Share Posted November 3, 2009 I have a database that stores record_date varchar(10) in the form of 2009/11/03. However I can not get it to return any data. Also I am running the query in mysqladmin. Will someone please advise what I am doing wrong. Here is my query. Select * from 'record' where record_date = 2009/11/03 Quote Link to comment https://forums.phpfreaks.com/topic/180148-search-help/ Share on other sites More sharing options...
Mchl Posted November 3, 2009 Share Posted November 3, 2009 In general you should NOT store dates in VARCHAR(). There's DATE datatype for that. Doing so will also allow you for easy comapring dates, adding, substracting etc, while in VARCHAR it will be much more difficult and less effiicient. In particular: Select * from 'record' where record_date = '2009/11/03' Quote Link to comment https://forums.phpfreaks.com/topic/180148-search-help/#findComment-950343 Share on other sites More sharing options...
lmhart Posted November 3, 2009 Author Share Posted November 3, 2009 Thanks. that works. I agree with you but I can not figure out how to store a date with out using a varchar. My info is being input after the fact and some can take up to two weeks to post. I want it to reflect the date it occured not the date entered. So a time date stamp did not work. Quote Link to comment https://forums.phpfreaks.com/topic/180148-search-help/#findComment-950356 Share on other sites More sharing options...
Mchl Posted November 3, 2009 Share Posted November 3, 2009 You can enter whatever date you wish into a datefield (within limits described in manual) and whenever you wish. You just need to remember that it's in YYYY-MM-DD format (you can use different separators, it's just the order that counts) Quote Link to comment https://forums.phpfreaks.com/topic/180148-search-help/#findComment-950359 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.