在PHP上定义错误的SQL查询日期

时间:2015-08-05 07:06:37

标签: php sql oracle

我正试图通过这种方式访问​​数据库:

$query="SELECT VAR1, VAR2  FROM TABLE WHERE DATE1 = TO_DATE('2010/01/01 01:00:00','YYYY/MM/DD hh24:mm:ss')";
$stmt = oci_parse($conn, $query);
oci_execute($stmt);

但我收到此错误: 警告:oci_execute():在第79行的C:\ Program Files \ EasyPHP-DevServer-14.1VC11 \ data \ localweb \ monitorizaR \ uploader.php

但是如果我通过这种方式放置代码行,它就会起作用..

$query="SELECT VAR1, VAR2  FROM TABLE WHERE DATE1 = TO_DATE('2010/01/01','YYYY/MM/DD')";
$stmt = oci_parse($conn, $query);
oci_execute($stmt);

对于日期格式来说肯定是个愚蠢的事情,但我尝试了很多方法。

问候!

2 个答案:

答案 0 :(得分:1)

您的minute部分日期不正确,mi不是mm

SELECT
    VAR1, 
    VAR2  
FROM TABLE 
WHERE DATE1 = TO_DATE('2010/01/01 01:00:00','YYYY/MM/DD hh24:mi:ss')

答案 1 :(得分:0)

您的日期格式错误。尝试

 override func tableView(tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath)
 {
     let controller = self.storyboard?.instantiateViewControllerWithIdentifier("ListDetailViewController") as ListDetailViewController
     controller.delegate = self
     controller.checklistToEdit = dataModel.lists[indexPath.row]
     self.presentViewController(controller, animated: true, completion: nil)
     }