Using CURDATE, DATE_SUB and DATE_ADD

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

 



I am using the query below in attempting to control access to a web site.
The idea is that today's date must be between 1 month before the start date
and 1 month after the finish date.

$query1 = "SELECT VFT_name FROM `vft` WHERE CURDATE() >
DATE_SUB(VFT_date_start, INTERVAL 1 month) AND CURDATE() <
DATE_ADD(VFT_date_finish, INTERVAL 1 month) ";

It seems that if a start date is say March 31, then any date in February
(even Feb 01) is going to return true. I tried using days (28, 29, .. 35
etc) instead of 1 month in the query but that doesn't seem to work.

For a start-date of March 11 how can I deny access on Feb 10 but allow
access starting on Feb 11?

Thanks for any help.

Barrie
-------------------------------------------------------
Barrie Matthews, Webmaster

Heurisko Ltd, Learning Technology Specialists
Spark House, 5 Durham St, PO Box 8577, Christchurch, New Zealand
P +64 3 353-7360    F +64 3 366-5488
b.matthews@heurisko.co.nz        www.heurisko.co.nz

Heurisko services:
- LEARNZ, NZ's award winning online education programme www.learnz.org.nz/
- TheSchoolDaily - daily education news and features
www.theschooldaily.com/
- NZ agent for TextHELP! products - award winning learning disability
software www.texthelp.co.nz/
- Suppliers of digital cameras, scanners, printers and POLYCOMS
www.heurisko.co.nz/teachingtools/
- Web server hosting and internet/intranet solutions
www.heurisko.co.nz/webservices/
-------------------------------------------------------



-- 
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