View previous topic :: View next topic |
Author |
Message |
satyenderd Beginner
Joined: 26 Aug 2005 Posts: 144 Topics: 73
|
Posted: Mon Jul 14, 2008 11:12 am Post subject: date calculation (-401 error) |
|
|
Could any one suggest how to correct the following query for which i am getting -401 error:
Herein I am trying to get the data of 5yrs from current date.
SELECT * FROM TABLENAME
WHERE UPSTAMP >= CURRENT DATE - 5 YEARS;
Thanks in advance. _________________ Satya |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Jul 14, 2008 11:22 am Post subject: |
|
|
satyenderd,
I am guessing that UPSTAMP is a Timestamp field and you are trying to compare it with a date. It is incompatible. Check this link for explanation of -401
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNMCJ12/2.3.152?
If UPSTAMP is indeed a timestamp field then try using
Code: |
WHERE DATE(UPSTAMP) >= CURRENT DATE - 5 YEARS; |
|
|
Back to top |
|
|
satyenderd Beginner
Joined: 26 Aug 2005 Posts: 144 Topics: 73
|
Posted: Mon Jul 14, 2008 11:26 am Post subject: ..and timestamp is in the following format |
|
|
..and timestamp is in the following format
2002-01-15-01.14.42.563275
Thanks in advance _________________ Satya |
|
Back to top |
|
|
satyenderd Beginner
Joined: 26 Aug 2005 Posts: 144 Topics: 73
|
Posted: Mon Jul 14, 2008 11:29 am Post subject: Thanks Kolusu a lot |
|
|
Kolusu,
Thanks a lot for your quick reply.
Thank once again.
Its working fine now..
Have a nice day. _________________ Satya |
|
Back to top |
|
|
Eric.C.Bakke Beginner
Joined: 14 Jul 2008 Posts: 15 Topics: 0 Location: Plano, TX
|
Posted: Mon Jul 14, 2008 5:37 pm Post subject: |
|
|
Or better, try
Code:
WHERE UPSTAMP >= CURRENT TIMESTAMP - 5 YEARS; _________________ Eric C. Bakke
Senior DB2 DBA |
|
Back to top |
|
|
satyenderd Beginner
Joined: 26 Aug 2005 Posts: 144 Topics: 73
|
Posted: Mon Jul 14, 2008 5:39 pm Post subject: |
|
|
Thanks Eric _________________ Satya |
|
Back to top |
|
|
|
|