-4

i have this error: "Parse error: syntax error, unexpected T_LNUMBER in line 14 " i would like to calculate difference between two dates

function datedifference()
{
   $res=dbconnect()->exec("SELECT DATEDIFF("2017-06-25", "2017-06-15");");

   echo $res;
}
mega6382
  • 9,211
  • 17
  • 48
  • 69

1 Answers1

1

The problem is that your string syntax is wrong, you have not escaped the " quotes inside the string, you can either use ' single-quote or escape the double quote:

Single-quote:

$res = dbconnect()->exec("SELECT DATEDIFF('2017-06-25', '2017-06-15');");

Escaped double quote:

$res = dbconnect()->exec("SELECT DATEDIFF(\"2017-06-25\", \"2017-06-15\");");
mega6382
  • 9,211
  • 17
  • 48
  • 69