RE: Date Range Question...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	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:holmes072000@charter.net]
Sent: Tuesday, February 04, 2003 10:04 AM
To: NIPP, SCOTT V (SBCSI); php-db@lists.php.net
Subject: Re:  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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux