MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

date calculation (-401 error)

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
satyenderd
Beginner


Joined: 26 Aug 2005
Posts: 144
Topics: 73

PostPosted: Mon Jul 14, 2008 11:12 am    Post subject: date calculation (-401 error) Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Jul 14, 2008 11:22 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
satyenderd
Beginner


Joined: 26 Aug 2005
Posts: 144
Topics: 73

PostPosted: Mon Jul 14, 2008 11:26 am    Post subject: ..and timestamp is in the following format Reply with quote

..and timestamp is in the following format


2002-01-15-01.14.42.563275



Thanks in advance
_________________
Satya
Back to top
View user's profile Send private message
satyenderd
Beginner


Joined: 26 Aug 2005
Posts: 144
Topics: 73

PostPosted: Mon Jul 14, 2008 11:29 am    Post subject: Thanks Kolusu a lot Reply with quote

Kolusu,

Thanks a lot for your quick reply.

Thank once again.

Its working fine now..

Have a nice day.
_________________
Satya
Back to top
View user's profile Send private message
Eric.C.Bakke
Beginner


Joined: 14 Jul 2008
Posts: 15
Topics: 0
Location: Plano, TX

PostPosted: Mon Jul 14, 2008 5:37 pm    Post subject: Reply with quote

Or better, try

Code:

WHERE UPSTAMP >= CURRENT TIMESTAMP - 5 YEARS;
_________________
Eric C. Bakke
Senior DB2 DBA
Back to top
View user's profile Send private message
satyenderd
Beginner


Joined: 26 Aug 2005
Posts: 144
Topics: 73

PostPosted: Mon Jul 14, 2008 5:39 pm    Post subject: Reply with quote

Thanks Eric
_________________
Satya
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group