Re: Syntax Error-Help!! Ty wrote:
> Syntax Error-Help!!
>
> My error "SQL0180N The syntax of the string representation of a
> datetime value is incorrect. SQLSTATE=22007" .
>
> I'm using yyyy-mm-dd. I can see the dates in a column on another
> query as 2007-06-17 23:00:13.827584 which is yyyy-mm-dd time(i
> guess).
>
> My attempt:
> SELECT <column_list>
> FROM ABXDB01.mdall_rec_holdg
> WHERE ABX_REQ_BUCKT = 'OK'
> AND CMPL_Q_DT > '2008-03-01';
>
> 2nd attempt:
> AND CMPL_Q_DT > '2008-03-01'
>
> 3rd attempt:
> AND CMPL_Q_DT > '2008-03-01%';
>
> 4th attempt without the DT works ok:
>
> SELECT <column_list>
> FROM ABXDB01.mdg_req_holdg
> WHERE ABX_REQ_BUCKT = 'OK'
DB2 interprets '2008-03-01' as a date, and CMPL_Q_DT is
(presumably) a timestamp. So, use either:
CMPL_Q_DT > '2008-03-01-00.00.00.000000'
or
DATE(CMPL_Q_DT) > '2008-03-01'
The latter form will preclude the use of any index on the
CMPL_Q_DT column, so you're better off specifying the full
timestamp. |