CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Select data based on date range from now

Print topic Send  topic

Author Message
jmwhooper

Posts: 7
Posted: 03/18/2004, 8:22 AM

I'm trying to write an sql query which pulls data from 7 days before and 7 days after today.

Something like this:
SELECT * FROM table WHERE date BETWEEN NOW() - 7 OR NOW() + 7

Please help!
View profile  Send private message
Riccardo Novello
Posted: 03/18/2004, 9:34 AM

MySQL syntax:

SELECT * FROM table
WHERE ( date >= DATE_SUB(NOW(),INTERVAL 7 DAY) )
AND ( date <= DATE_ADD(NOW(),INTERVAL 7 DAY) )


"jmwhooper" <jmwhooper@forum.codecharge> ha scritto nel messaggio
news:54059ccc13ee5b@news.codecharge.com...
> I'm trying to write an sql query which pulls data from 7 days before
and 7 days after today.
>
> Something like this:
> SELECT * FROM table WHERE date BETWEEN NOW() - 7 OR NOW() + 7
>
> Please help!
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

vituskung
Posted: 03/19/2004, 12:00 AM

Date manipulation looks horrible for me in php/mysql as an asp programmer.

I would appreciate if anyone can help me on how I can calculate the number of days between 2 date fields.

I tried ($xxx->date1->GetValue() - $xxx->date1->GetValue()) and many other ways and it doesn't work.
vituskung
Posted: 03/19/2004, 7:22 AM

I managed to do it with array. Thanks!

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.