CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Date calculations

Print topic Send  topic

Author Message
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.
View profile  Send private message
montymoose


Posts: 85
Posted: 08/05/2007, 4:38 AM

Don't worry about it guys - fixed it! ;)
View profile  Send private message
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??
View profile  Send private message
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.
View profile  Send private message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.