Postgresql无效的日期格式错误

时间:2017-02-07 19:02:52

标签: postgresql

在我的postgresql查询中,我收到此错误:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
            keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {

        // Handling the event
    } else if (keyCode == KeyEvent.KEYCODE_BACK) {
        this.setFocusable(false);
        this.setFocusableInTouchMode(false);
        this.clearFocus();
    }

    return false;
}

log_field2字段是一个varchar数据类型,我做了一个转换为日期(:: date),然后检查了名为{START_DATE}和{END_DATE}的参数中的值,并将它们放在单引号中但无效。有人可以提供一些方向/帮助,问题可能是什么?任何帮助表示赞赏。

这是我的问题:

Error: SQL Error: SQLSTATE[22007]: Invalid datetime format: 7 ERROR: invalid input syntax for type date: "'"

1 个答案:

答案 0 :(得分:0)

您必须将{SYEAR},'{START_DATE}','{END_DATE}'更改为某个值:

SELECT sle.source_id, 
       count(sle.*),
       sum(coalesce(log_field20::numeric, 0)) || ' min' as duration_total
 FROM custom_field_log_entries sle 
INNER JOIN student_enrollment se 
        ON (sle.source_id=se.student_id and se.custom_9 is null 
           AND se.syear = 2017 
           AND se.end_date is null)
INNER JOIN schools sc ON (se.school_id=sc.id) 
WHERE sle.field_id = 328
     AND log_field2::date BETWEEN '2017-01-10' AND '2017-01-25'
     AND (log_field20 ~ '^[0-9]+$' or log_field20 is null) --{SCHOOL_SPECIFIC} 
     AND se.school_id = 1 -- {SCHOOL_ID}
GROUP BY sle.source_id