Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old February 14th, 2004, 05:48 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
mysql select between help

Need to select * bewteen $x,$y statement but can't quite get the syntax
php Code:
Original - php Code
  1.  
  2. $startye = date($_POST['startYear']); //set a format a start year
  3. $startm = date($_POST['startMonth']); // set a format start month
  4. $startd = date($_POST['startDay'])// set a format start day
  5. $startDate="$startye-$startm-$startd"; //slap start date all together
  6. // -------
  7. $endye = date($_POST['endYear']); //set a format a end year
  8. $endm = date($_POST['endMonth']); // set a format end month
  9. $endd = date($_POST['endDay'])// set a format end day
  10. $endDate="$endye-$endm-$endd"; //slap end date all together
  11.  
  12. SELECT distinct cust_serv_agent_id FROM `cust_serv`
  13.     where DATE_FORMAT(cust_serv_agent_time_compl, '%Y-%c-%e') in '$startDate', '$endDate'

Reply With Quote
  #2  
Old February 14th, 2004, 08:07 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: mysql select between help

I am not sure if this is what you are looking for, but you can use the between keyword...

SELECT distinct cust_serv_agent_id FROM `cust_serv`
where DATE_FORMAT(cust_serv_agent_time_compl, '%Y-%c-%e') between '$startDate' and '$endDate'

This would also include the start and end dates in the selection process. Another way to do it would be...

SELECT distinct cust_serv_agent_id FROM `cust_serv`
where DATE_FORMAT(cust_serv_agent_time_compl, '%Y-%c-%e') > '$startDate' and DATE_FORMAT(cust_serv_agent_time_compl, '%Y-%c-%e')<'$endDate'

this would only return dates that are between those two dates.


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > mysql select between help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT