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
|
|
|
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!
|
|
|
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 |
|
|
|