Calculating months and years of 2 dates using

Hi all,

I am trying to get amount of how many weeks and how many months and years from 2 dates and this is what i have atmm


$today=date("20100317");
$joineddate=date("20010121");
$Query="SELECT DATEDIFF($today)-DATEDIFF($joineddate) FROM members WHERE username='$username'";
	echo $Query;
	$result = mysqli_query($con,$Query);
	if(!$result)
	{
	 mysqli_error($con);	
	}
	if($result)
	{
	   $days = mysqli_fetch_array($result);
	   return $days[0];
	}

Its not working the way i want though am i doing somthing wrong,

Any help would be good,Thanks

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_datediff
http://php.net/manual/en/function.date.php

You are doing a few things wrong. Perhaps read those links and come back if you still have problems.

the mysql DATEDIFF function requires two parameters, not one

this type of confusion could easily be avoided with a very quick, very simple check of da manual

we’ve been through this before :slight_smile: