Re: [PHP-DB] Date Range Question...

2003-02-04 Thread 1LT John W. Holmes
 I am working on an app that needs to post information to a website
 based on date.  The tricky part for me is that the date is a range that
 spans either 2 or 3 days.  I want the web page to dynamically populate
this
 information based on a query.  The query will look something like this:
 mysql(Calendar2,SELECT StartDate, StopDate, LocationID FROM
 phpCalendar_Daily WHERE StartDate=CURDATE() )

 My question is say for example the StartDate is actually Jan. 1.
 The page is accessed on Jan. 2 or Jan. 3...  The  StartDate for the next
 entry is Jan. 4.  How do I write this query to select the proper entry?
In
 doing some research, it appears that a MySQL SELECT CASE might do the
 trick, but I have never used this before.  The other option I can envision
 is using PHP to handle the login and simply running the query, testing the
 result, if NULL, run the query again with CURDATE(-1).
 Any hints, ideas, or suggestions would be most appreciated.  Thanks
 in advance.

If I understand you correctly, I think you could use something like this:

SELECT StartDate, StopDate, LocationID FROM phpCalendar_Daily WHERE
StartDate BETWEEN CURDATE() AND CURDATE() - INTERVAL $x DAY

Where $x is 2 or 3, depending on your case.

---John Holmes...


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




RE: [PHP-DB] Date Range Question...

2003-02-04 Thread NIPP, SCOTT V (SBCSI)
WOW...  I have never even heard of BETWEEN before.  How does this
look to you?

SELECT StartDate, StopDate, LocationID FROM phpCalendar_Daily WHERE
CURDATE() BETWEEN StopDate AND StopDate

Would the query work like this?  This would mean I don't even have
to care about the difference of 2 or 3 days?

-Original Message-
From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 04, 2003 10:04 AM
To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Date Range Question...


 I am working on an app that needs to post information to a website
 based on date.  The tricky part for me is that the date is a range that
 spans either 2 or 3 days.  I want the web page to dynamically populate
this
 information based on a query.  The query will look something like this:
 mysql(Calendar2,SELECT StartDate, StopDate, LocationID FROM
 phpCalendar_Daily WHERE StartDate=CURDATE() )

 My question is say for example the StartDate is actually Jan. 1.
 The page is accessed on Jan. 2 or Jan. 3...  The  StartDate for the next
 entry is Jan. 4.  How do I write this query to select the proper entry?
In
 doing some research, it appears that a MySQL SELECT CASE might do the
 trick, but I have never used this before.  The other option I can envision
 is using PHP to handle the login and simply running the query, testing the
 result, if NULL, run the query again with CURDATE(-1).
 Any hints, ideas, or suggestions would be most appreciated.  Thanks
 in advance.

If I understand you correctly, I think you could use something like this:

SELECT StartDate, StopDate, LocationID FROM phpCalendar_Daily WHERE
StartDate BETWEEN CURDATE() AND CURDATE() - INTERVAL $x DAY

Where $x is 2 or 3, depending on your case.

---John Holmes...

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