montymoose
Posts: 85
|
| Posted: 08/05/2007, 2:00 AM |
|
Hi,
Wonder if any of you SQL guru's have got 2 secs to helpe me out.
I have two grids showing news stories from a database. Each record has a publish date. On the first grid I want to show all records with a datetime GREATER than the current datetime. and on the second grid I want to show records which are EQUAL or LESS to the current datetime.
Here's what I've come up with: (which doesn't work properly)
GRID 1
WHERE news_pubdate > (NOW()-1)
GRID 2
WHERE news_pubdate <= (NOW()+1)
Any more suggestions....
Thanks
John.
|
 |
 |
montymoose
Posts: 85
|
| Posted: 08/05/2007, 4:38 AM |
|
Don't worry about it guys - fixed it! ;)
|
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 08/05/2007, 7:58 PM |
|
montymoose
Just for the possiblility of helping others, what was the solution that you came up with??
|
 |
 |
montymoose
Posts: 85
|
| Posted: 08/06/2007, 5:25 AM |
|
The above solution does in fact work - I had accidently created another problem unrelated. If you want to do the same thing, use the code at the top of this post.
|
 |
 |
Joachim Uersfeld
|
| Posted: 08/06/2007, 6:19 AM |
|
> On the first grid I want to show all records with a datetime GREATER
than the current datetime. <
mySQL, days only:
WHERE TO_DAYS(news_pubdate) > TO_DAYS(NOW())
mySQL, datetime:
WHERE news_pubdate > NOW()
> and on the second grid I want to show records which are EQUAL or LESS
to the current datetime. <
mySQL, days only:
WHERE TO_DAYS(news_pubdate) <= TO_DAYS(NOW())
mySQL, datetime:
WHERE news_pubdate <= NOW()
Joachim
|
|
|
 |
klwillis
Posts: 428
|
| Posted: 08/06/2007, 7:49 PM |
|
NOW() returns both a date and timestamp - like SYSDATE().
Use CURDATE() to return just the date:
GRID 1
WHERE news_pubdate > (CURDATE()-1)
GRID 2
WHERE news_pubdate <= (CURDATE()+1)
Quote montymoose:
Hi,
Wonder if any of you SQL guru's have got 2 secs to helpe me out.
I have two grids showing news stories from a database. Each record has a publish date. On the first grid I want to show all records with a datetime GREATER than the current datetime. and on the second grid I want to show records which are EQUAL or LESS to the current datetime.
Here's what I've come up with: (which doesn't work properly)
GRID 1
WHERE news_pubdate > (NOW()-1)
GRID 2
WHERE news_pubdate <= (NOW()+1)
Any more suggestions....
Thanks
John.
_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"
Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006 |
 |
 |
|