CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Counting days

Print topic Send  topic

Author Message
travel-net

Posts: 56
Posted: 03/25/2004, 7:41 AM

Hello,

Is there a way to count the number of days between two fields with dates in it? If so, can you give me an example.

Regards,
Frans
View profile  Send private message
Anothersledhead


Posts: 44
Posted: 03/25/2004, 10:46 AM

If the dates are comming from an sql database you can run an sql query that will give you the number of days between the two dates. I don't know if the syntax is right but something like this might work for you.
--------------------------------------------------------------------------------------------------------------------
SELECT ((YEAR(first_date)*365) + (DAYOFYEAR(first_date))) - ((YEAR(second_date)*365) + (DAYOFYEAR(second_date))) AS number_of_days FROM table_name
--------------------------------------------------------------------------------------------------------------------
SELECT ((YEAR('2003-09-09')*365) + (DAYOFYEAR('2003-09-09'))) - ((YEAR('2000-05-05')*365) + (DAYOFYEAR('2000-05-05'))) AS number_of_days
--------------------------------------------------------------------------------------------------------------------
There may be a cleaner way but things get complicated when you are dealing with diffrent years. Hope this helps!
View profile  Send private message
peterr


Posts: 5971
Posted: 03/25/2004, 2:44 PM

Also try:
http://www.google.com/search?q=php+calculate+difference+between+dates

Especially here is good info:
http://www.google.com/search?q=php+date+difference+site%3Aphp.net
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
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.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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