Hello,
I have 2 dates lets say: 1-1-2005 and 5-1-2005. Now there are 5 days in those dates. I want to get the days from the 2 specified days.
How do i do that ? Please help.
Thanks.
Printable View
Hello,
I have 2 dates lets say: 1-1-2005 and 5-1-2005. Now there are 5 days in those dates. I want to get the days from the 2 specified days.
How do i do that ? Please help.
Thanks.
Hi,
I was trying this query but it does not seems to be working and i am getting an error instead:
$q3 = "SELECT DATEDIFF ('" . $a1["sdate"] . " 23:59:59', '" . $a1["fdate"] . "')";
$r3 = mysql_query($q3) or die(mysql_error());
echo mysql_result($r3, 0);
The error i am getting is:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '('2005-05-10 23:59:59', '2005-06-18')' at line 1
Please help.
Thanks
Manavo11 gave you a link in this thread which shows you exactly how to do this.Quote:
Originally Posted by AvisSoft
Hi,
Thanks for that code..but i got around with that using the following code. Here it is maybe it will help others also who don't wanna get involved in mysql:
ThanksPHP Code:$sVar_dateString1 = $a1["sdate"];
$sVar_dateString2 = $a1["fdate"];
$aVar_date1 = explode('-', $sVar_dateString1);
$aVar_date2 = explode('-', $sVar_dateString2);
$iVar_time1 = mktime(0,0,0,$aVar_date1[1],$aVar_date1[2], $aVar_date1[0]);
$iVar_time2 = mktime(0,0,0,$aVar_date2[1],$aVar_date2[2], $aVar_date2[0]);
$iVar_timeDifference = $iVar_time2 - $iVar_time1;
$iVar_dayDifference = ($iVar_timeDifference / (60 * 60 * 24)) + 1;
echo $iVar_dayDifference;