[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 10-24-2005, 05:56 AM   #1 (permalink)
NamePros Member
 
Join Date: Sep 2005
Posts: 30
57.00 NP$ (Donate)

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, 05:10 PM   #2 (permalink)
Domains my Dominion
 
sdsinc's Avatar
 
Join Date: Aug 2005
Location: Web 1.0
Posts: 6,284
1,095.94 NP$ (Donate)

sdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond repute

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
Like this ?

PHP Code:
select * from your_table  where date_field > CURDATE()
__________________
Buy now - MassDeveloper.com $500
sdsinc is offline  
Old 10-24-2005, 07:29 PM   #3 (permalink)
NamePros Member
 
Join Date: May 2005
Location: USA
Posts: 91
858.40 NP$ (Donate)

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-24-2005, 11:27 PM   #4 (permalink)
NamePros Member
 
Join Date: Sep 2005
Posts: 30
57.00 NP$ (Donate)

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, 07:23 AM   #5 (permalink)
Domains my Dominion
 
sdsinc's Avatar
 
Join Date: Aug 2005
Location: Web 1.0
Posts: 6,284
1,095.94 NP$ (Donate)

sdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond repute

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
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.
__________________
Buy now - MassDeveloper.com $500
sdsinc is offline  
Old 10-26-2005, 12:04 AM   #6 (permalink)
NamePros Member
 
Join Date: Sep 2005
Posts: 30
57.00 NP$ (Donate)

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

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, 03:09 AM   #7 (permalink)
Domains my Dominion
 
sdsinc's Avatar
 
Join Date: Aug 2005
Location: Web 1.0
Posts: 6,284
1,095.94 NP$ (Donate)

sdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond repute

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
Fine. If I were you I would run a query to convert the values to a more convenient (date) format
__________________
Buy now - MassDeveloper.com $500
sdsinc is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
soooo many yahoo's redhippo Domain Name Discussion 5 07-12-2005 11:26 PM
ReleaseDates.com jumpbug Domain Appraisals 11 06-30-2005 09:37 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 02:21 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85