| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Sep 2005
Posts: 30
![]() | Date Query Problem I have got date stored in MySQL in this format "Sat, 22 Oct 2005 - 19:30:00" and I want to write a query to select ALL records with DATE coming AFTER the CURRENT DATE or TODAY. In other words I want to select all future dates only. Can anyone help ? http://www.binarytrends.com |
| |
| | #2 (permalink) |
| Domains my Dominion Join Date: Aug 2005 Location: Web 1.0
Posts: 9,552
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Like this ? PHP Code:
__________________ NameNewsletter.com - free lists of available domain names ZoneFiles.net (beta) - ccTLD and gTLD droplists |
| |
| | #3 (permalink) |
| NamePros Member Join Date: May 2005 Location: USA
Posts: 93
![]() | Would this work? Code: SELECT * from your_table WHERE date_field > date('D, j M Y - h:i:s')
__________________ Girl Arcades.com - Girl Themed Topsite JOIN NOW TalkChevelles.com for sale. FlameGames.com - Online Arcade |
| |
| | #5 (permalink) |
| Domains my Dominion Join Date: Aug 2005 Location: Web 1.0
Posts: 9,552
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Shahid, May I ask why you don't store the date field as datetime ? You can use the my_sql date_format function to format the display of the date in your queries then.
__________________ NameNewsletter.com - free lists of available domain names ZoneFiles.net (beta) - ccTLD and gTLD droplists |
| |
| | THREAD STARTER #6 (permalink) |
| NamePros Member Join Date: Sep 2005
Posts: 30
![]() | I made a mistake long ago by making this field a varchar and storing the date and time in a english style date and now I got in trouble. But I have finally got round it ![]() ????: NamePros.com http://www.namepros.com/showthread.php?t=134491 Thanks everyone. I finally got round it by using this : DATEDIFF(str_to_date(right(myDateField, 22),'%d %b %Y'),CURDATE())>0 So if anyone ever makes a mistakes by making a date field VARCHAR, this is the solution to compare it with current date ![]() Thanks http://www.binarytrends.com |
| |
| | #7 (permalink) |
| Domains my Dominion Join Date: Aug 2005 Location: Web 1.0
Posts: 9,552
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Fine. If I were you I would run a query to convert the values to a more convenient (date) format
__________________ NameNewsletter.com - free lists of available domain names ZoneFiles.net (beta) - ccTLD and gTLD droplists |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| soooo many yahoo's | redhippo | Domain Name Discussion | 5 | 07-13-2005 12:26 AM |
| ReleaseDates.com | jumpbug | Domain Appraisals | 11 | 06-30-2005 10:37 AM |
| ReleaseDates.com | jumpbug | Domains For Sale - Make Offer | 0 | 06-29-2005 09:03 PM |