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

 A couple of quick SQL date queries I just can't get to work!

Print topic Send  topic

Author Message
montymoose


Posts: 85
Posted: 08/07/2007, 7:48 AM

Hi,

I have a couple of date calculations which I need to use in my latest project. I've tried a number of SQL commands, but each seem to fail. If any of you SQL daddies have a few minutes spare, you could save me hours of messing about with scripts.

Problem 1:

I have a news database which now has many years of daily news each as individual records. I have been asked to provide a 'today in 2006' section which returns rows with a datestamp that matches the current date minus 1 year. so Today would pull any records with the date: 07/08/2006.

Problem 2:

I need to also return all records which have a date stamp which is not older than 3 weeks. The last 3 weeks worth of news if you like.

Thanks in advance,

John.
View profile  Send private message
mamboBROWN


Posts: 1713
Posted: 08/07/2007, 3:36 PM

montymoose
I am going to assume that you are using MySQL. If this is the case then try using these MySQL functions in your where statement DATE_ADD(), DATE_SUB() and if you are using MySQL 4.1.1 you can use DATEDIFF().

NOTE: If you are new to MySQL I would suggest downloading thier CHM for MySQL it is a good reference to have for occassions like this.
View profile  Send private message
montymoose


Posts: 85
Posted: 08/08/2007, 12:58 AM

Thanks,
View profile  Send private message
mamboBROWN


Posts: 1713
Posted: 08/08/2007, 4:53 PM

montymoose
No problem, glad I could be of service :-).
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.