Re: [PHP] Selecting Date Range

2004-11-03 Thread Greg Donald
On Wed, 3 Nov 2004 13:47:38 -0500, ConbuD [EMAIL PROTECTED] wrote:
 Hey, I have a database with approx 200-300 students in it. I wanna be able
 to pull out what student joined a class with in a certain date range. Say I
 wanna get all the students who joined between 10/12/04 through 12/12/04.
 What is the easiest way to do this ? Can it be done with just a simple MySQL
 query ? I actually enter the date as shown above, I dont use the MySQL
 dates. Any help will be greatly appreciated.

Where's the PHP code you're using now?  What does the query look like in there?

You probably want something like this:

SELECT
*
FROM
students
WHERE
join_date = '10/12/04'
AND
join_date = '12/12/04';

But I'm doubting your dates are stored in that format, and I bet
there's more than one table to consider as well.  Again, where's the
PHP code you're asking a question about?


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Selecting Date Range

2004-11-03 Thread Jay Blanchard
[snip]
Can it be done with just a simple MySQL query ?
[/snip]

Yes.
WHERE `date` BETWEEN `startDate` AND `endDate` 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Selecting Date Range

2004-11-03 Thread John Nichel
ConbuD wrote:
Hey, I have a database with approx 200-300 students in it. I wanna be able 
to pull out what student joined a class with in a certain date range. Say I 
wanna get all the students who joined between 10/12/04 through 12/12/04. 
What is the easiest way to do this ? Can it be done with just a simple MySQL 
query ? I actually enter the date as shown above, I dont use the MySQL 
dates. Any help will be greatly appreciated.
Look at BETWEEN in MySQL.
http://dev.mysql.com/doc/mysql/en/Comparison_Operators.html
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Selecting Date Range

2004-11-03 Thread Jason Wong
On Wednesday 03 November 2004 18:47, ConbuD wrote:
 Hey, I have a database with approx 200-300 students in it. I wanna be able
 to pull out what student joined a class with in a certain date range. Say I
 wanna get all the students who joined between 10/12/04 through 12/12/04.
 What is the easiest way to do this ? Can it be done with just a simple
 MySQL query ? I actually enter the date as shown above, I dont use the
 MySQL dates. Any help will be greatly appreciated.

If you're not storing your dates as a real date/time column but as simple 
varchar column then you've created unnecessary work for yourself. I strongly 
suggest that you use proper date column types and then you can take advantage 
of the date handling functions available in MySQL.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
A beer delayed is a beer denied.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php