bigrossco Posted February 8, 2007 Share Posted February 8, 2007 I have a database that has dates on it for jobs and want a page to dispaly anything that is in the database / form which is equal to that days date i.e. if a record on the database has 08-01-2007 it should only show stuff from that date (today) and nothing else r Quote Link to comment https://forums.phpfreaks.com/topic/37603-solved-date-query/ Share on other sites More sharing options...
trq Posted February 8, 2007 Share Posted February 8, 2007 SELECT datefld FROM tbl WHERE datefld = '08-01-2007'; Quote Link to comment https://forums.phpfreaks.com/topic/37603-solved-date-query/#findComment-179802 Share on other sites More sharing options...
bigrossco Posted February 8, 2007 Author Share Posted February 8, 2007 sorry should of said i want it to use the current date automaticly i.e. system date Quote Link to comment https://forums.phpfreaks.com/topic/37603-solved-date-query/#findComment-179822 Share on other sites More sharing options...
obsidian Posted February 8, 2007 Share Posted February 8, 2007 sorry should of said i want it to use the current date automaticly i.e. system date The best thing to do is to change your data type to a SQL recognized DATE or DATETIME field. This way, you can immediately do matches against the current date and/or time with the built in functions such as DATE() or NOW(). In the interim, though, you could probably just do this: SELECT * FROM tbl WHERE dtfld = DATE_FORMAT(NOW(), "%m-%d-%Y"); Quote Link to comment https://forums.phpfreaks.com/topic/37603-solved-date-query/#findComment-179825 Share on other sites More sharing options...
bigrossco Posted February 8, 2007 Author Share Posted February 8, 2007 jsut so you know my date field is as a date type on the database Quote Link to comment https://forums.phpfreaks.com/topic/37603-solved-date-query/#findComment-179830 Share on other sites More sharing options...
obsidian Posted February 8, 2007 Share Posted February 8, 2007 jsut so you know my date field is as a date type on the database Good... your description of the 08-01-2007 format threw me off. Typically, a SQL DATE field is YYYY-MM-DD format. Quote Link to comment https://forums.phpfreaks.com/topic/37603-solved-date-query/#findComment-179871 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.