Page 1 of 1

SQLCODE -401 in a Date calculation.

Posted: Sat Sep 26, 2015 8:50 am
by Kavya Arora
Hi,

I am using a query for date calculation in my COBOL Program. The query is like this:

Code: Select all

SELECT * FROM TABLENAME 
WHERE AKSTAMP >= CURRENT DATE - 3 YEARS; 
where AKSTAP has the format like: 2015-09-15-01.13.32.563275

Could any one suggest how to correct the query, as I get SQLCODE -401 with above query.

Thanks in advance.

Re: SQLCODE -401 in a Date calculation.

Posted: Sat Sep 26, 2015 12:08 pm
by zprogrammer
AKSTAMP is a timestamp field you need to equate to a date field ,Hence try the query below

Code: Select all

SELECT * FROM TABLENAME 
WHERE DATE(AKSTAMP) >= CURRENT DATE - 3 YEARS;