lpxxfaintxx Posted February 10, 2009 Share Posted February 10, 2009 I have a database of events that have a table 'date' that has dates stored in the format "Month Day, Year." How would I make make a query that only selects dates that are in the future, and not past? For example, today is February 9, 2009. Let's say I have the following rows with the 'date' tables: January 4, 2009 January 31, 2009 February 21, 2009 February 26, 2009 How would I make it so that I only get "February 21, 2009" and "February 26, 2009," since they are UPCOMING, and not in the past? Hope that makes sense. thanks Quote Link to comment Share on other sites More sharing options...
printf Posted February 10, 2009 Share Posted February 10, 2009 change column to date, datetime, or timestamp because if you don't you will have write a long conversion in your query. Using the defined date format that the database natively supports is the only way to store dates and times. Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted February 10, 2009 Author Share Posted February 10, 2009 Thanks, I will look into that. What is the date format for MySQL? Is it YYYY-MM-DD? Also, when I echo out the date in PHP, how do I make the date more "user-friendly?" IE, how do I make it show up as "February 24, 2009" instead of "2009-02-24" After I change the column to date, then what do I do? Any query to get the dates in the future? Quote Link to comment Share on other sites More sharing options...
printf Posted February 10, 2009 Share Posted February 10, 2009 If you use any of the database date or time formats, then in your select use DATE_FORMAT() to format the return, example... SELECT DATE_FORMAT(date_column, '%M %e, %Y') AS date_column FROM ... // output example $row['date_column'] = January 1, 2009 DATE_FORMAT Reference Quote Link to comment 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.