View previous topic :: View next topic
|
Author |
Message |
johnjohn055
New User
Joined: 15 Aug 2008 Posts: 5 Location: PUNE
|
|
|
|
Hi,
My requirement is as follows. I need a query to Delete rows from Table A based on BILL_DATE is <= CURRENT DATE - 7 YERAS. BILL_DATE column is defined as CHAR (6) in TABLE A. So if i'll write Delete from Table A WHERE BILL_DATE is <= CURRENT DATE - 7 YERAS, getting sqlcode -180 because column is defined as char. As per my knowledge SUBSTR function won't support while Deleting from Table.
If anyone having any ideas please let me know.
Thanks
John |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
I wish designers would learn about DB2 before they start designing. What is the format of the data in BILL_DATE. |
|
Back to top |
|
|
Ajay Baghel
Active User
Joined: 25 Apr 2007 Posts: 206 Location: Bangalore
|
|
|
|
Hi John,
If the BILL_DATE is character string like below:
'2002-10-20'
You can issue the below query:
Delete from Table A WHERE
DATE(BILL_DATE) is <= ( CURRENT DATE - 7 YEARS )
Thanks,
Ajay |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Quote: |
-180 THE DATE, TIME, OR TIMESTAMP VALUE value IS INVALID
Explanation: The length or string representation of a DATE, TIME, or
TIMESTAMP value does not conform to any valid format.
|
It does not say a word about the column being CHAR. |
|
Back to top |
|
|
|