three weeks ago avg with cycle date passed through parm



IBM's flagship relational database management system

three weeks ago avg with cycle date passed through parm

Postby rekhamf » Wed Feb 01, 2012 8:15 pm

Hi ,

I need to get the values for 3 week average ,I will be passing the cycle date value to the query from the cobol program ..So i harded coded the cycle date as '2012-01-31' in the db2 query,to verify if this query works.. but its not fetching any records,though records are present , can any one please help on this :

 SELECT Stu_name,Stu_join_Date
   FROM Student_tbl               
   WHERE Stu_join_Date BETWEEN                     
   DATE (DATE(2012-01-31) - 24 DAYS) AND     
   DATE (DATE(2012-01-31) - 18 DAYS) WITH UR;



actual query in the pgm will be like :
SELECT Stu_name,Stu_join_Date
   FROM Student_tbl               
   WHERE Stu_join_Date BETWEEN                     
   DATE (DATE(:ws-cycledt) - 24 DAYS) AND     
   DATE (DATE(:ws-cycledt) - 18 DAYS) WITH UR;
rekhamf
 
Posts: 33
Joined: Mon Nov 28, 2011 5:09 am
Has thanked: 0 time
Been thanked: 0 time

Re: three weeks ago avg with cycle date passed through parm

Postby rekhamf » Wed Feb 01, 2012 8:58 pm

When it tried with stu_join_DATE = CURRENT DATE and made select on DATE(2012-02-01) ,it showing value as 0006-07-02
rekhamf
 
Posts: 33
Joined: Mon Nov 28, 2011 5:09 am
Has thanked: 0 time
Been thanked: 0 time

Re: three weeks ago avg with cycle date passed through parm

Postby Akatsukami » Wed Feb 01, 2012 9:10 pm

How is STU_JOIN_DATE defined? As DATE, or as something else?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: three weeks ago avg with cycle date passed through parm

Postby rekhamf » Wed Feb 01, 2012 9:22 pm

As Date , i gave like this DATE('2012-02-01') ,its worked out now ,,,
rekhamf
 
Posts: 33
Joined: Mon Nov 28, 2011 5:09 am
Has thanked: 0 time
Been thanked: 0 time


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post