how to use DATE FORMAT in my query?

前端 未结 2 1177
臣服心动
臣服心动 2021-01-28 16:48

this works on phpmyadmin , but gives me and error when I am using on the code, the error says ,Parse error: syntax error, unexpected \'%\'....

whats wrong with my sintax

相关标签:
2条回答
  • 2021-01-28 17:26

    It's because your string is terminated by single quotes $database->setQuery(' - just change to double quotes and it will work.

    $database->setQuery(" ");
    
    0 讨论(0)
  • 2021-01-28 17:37

    You have to escape the ' mark. So instead of

        DATE_FORMAT(quizSession.finished_on,'%M %d, %Y')
    

    try

        DATE_FORMAT(quizSession.finished_on,\'%M %d, %Y\')
    

    Or you can just use double quotes " to start and end the string.

    0 讨论(0)
提交回复
热议问题