Another date compare question
15 posts by 4 authors in: Forums > CMS Builder
Last Post: March 4, 2010 (RSS)
By gkornbluth - March 4, 2010
Mine too, but I think that I've got it working now.
Here's the 'where' that I used to show reception_ dates for the upcoming week, as you suggested.
'where' => '(NOW() + INTERVAL 7 DAY) >= reception_date AND reception_date >= TIMESTAMP(CURDATE(), "00:00:00")',
And here's the 'where' that I used to show all the other events (and leave out those already listed)
'where' => 'reception_date <= TIMESTAMP(NOW()) OR reception_date >= TIMESTAMP(NOW()+ INTERVAL 7 DAY)',
I'm still a little (lot) shaky about where to use CURDATE, NOW, TIMESTAMP and the 00:00:00, but I'll play some more and make sure that it works.
If you see something I've missed (without making your head hurt too much), please let me know.
One more question.
In my list viewer, I've repeated the entire page code twice, once for each set of 'where' conditions, and then changed the body code in each to suit. Is there a more elegant way to code this then repeating all of the code twice.
Thanks again and again for all you do.
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Another date compare question
By Dave - March 4, 2010
> Is there a more elegant way to code this then repeating all of the code twice.
I'm going to guess not, but if you'l like to attach your viewer file I can take a look and let you know any suggestions.
interactivetools.com
By gkornbluth - March 4, 2010
Thanks
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Another date compare question
By Chris - March 4, 2010
I'm assuming those are two separate pages which you've concatenated together for attaching to this thread?
While it's possible to factor out common code into include files or php functions, with such a small amount of code it would probably make things more complicated to do so. I think you're best off with what you have already. :)
Chris
Re: [chris] Another date compare question
By gkornbluth - March 4, 2010
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php