Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Calculations

Status
Not open for further replies.

gockle

Programmer
Joined
Oct 5, 2003
Messages
3
Location
AU
I am trying to calculate the subtraction of one date from another with the solution expressed in days. One date is stored in a MySQL Date field (YYYY-MM-DD)and the other generated using the php function date().

I have tried to_days() in MySQL but cannot match it with any php date function.

Any help would be appreciated.
 
see the mktime() function...

Known is handfull, Unknown is worldfull
 
using TO_DAYS() shd work.

Code:
$datefrom = date("Y-m-d",time()) ;

$query = "select TO_DAYS($datefrom) - TO_DAYS(datefromdb) as diff from tablename [where condition if any]..." ;


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Thankyou very much...all is now well using to_days().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top