NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Date Query Problem

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 10-24-2005, 06:56 AM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Sep 2005
Posts: 30
shahid_146 is an unknown quantity at this point
 



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
shahid_146 is offline  
Old 10-24-2005, 06:10 PM   #2 (permalink)
Domains my Dominion
 
sdsinc's Avatar
Join Date: Aug 2005
Location: Web 1.0
Posts: 9,552
sdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatness
 


Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer Animal Rescue Wildlife
Like this ?

PHP Code:
select from your_table  where date_field CURDATE() 
????: NamePros.com http://www.namepros.com/programming/134491-date-query-problem.html
__________________
NameNewsletter.com - free lists of available domain names
ZoneFiles.net (beta) - ccTLD and gTLD droplists
sdsinc is offline  
Old 10-24-2005, 08:29 PM   #3 (permalink)
NamePros Member
Join Date: May 2005
Location: USA
Posts: 93
InvertedVertex will become famous soon enough
 


9/11/01 :: Never Forget
Would this work?
Code:
SELECT * from your_table WHERE date_field > date('D, j M Y - h:i:s')
The date is formatted the way you have it.
InvertedVertex is offline  
Old 10-25-2005, 12:27 AM THREAD STARTER               #4 (permalink)
NamePros Member
Join Date: Sep 2005
Posts: 30
shahid_146 is an unknown quantity at this point
 



date query


thanks but i found that i was storing the date in a varchar field and mysql won't do a date calculation on a varchar in an english formated date. So I have to handle it with code in php.
shahid_146 is offline  
Old 10-25-2005, 08:23 AM   #5 (permalink)
Domains my Dominion
 
sdsinc's Avatar
Join Date: Aug 2005
Location: Web 1.0
Posts: 9,552
sdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatness
 


Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer Animal Rescue Wildlife
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
sdsinc is offline  
Old 10-26-2005, 01:04 AM THREAD STARTER               #6 (permalink)
NamePros Member
Join Date: Sep 2005
Posts: 30
shahid_146 is an unknown quantity at this point
 



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
shahid_146 is offline  
Old 10-26-2005, 04:09 AM   #7 (permalink)
Domains my Dominion
 
sdsinc's Avatar
Join Date: Aug 2005
Location: Web 1.0
Posts: 9,552
sdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatness
 


Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer Animal Rescue Wildlife
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
sdsinc is offline  
Closed Thread


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

Liquid Web Smart Servers  
All times are GMT -7. The time now is 08:51 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger