SQLCODE -401 in a Date calculation.

RDBMS from IBM and IBM's Hierarchical DBMS and Transaction Manager (IMS DC).
Post Reply
Kavya Arora
New Member
Posts: 5
Joined: Mon Jan 19, 2015 5:21 pm

SQLCODE -401 in a Date calculation.

Post 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.
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: SQLCODE -401 in a Date calculation.

Post 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;
zprogrammer
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DB2 and IMS DB/DC”