Date in Db2



IBM's flagship relational database management system

Date in Db2

Postby surime72 » Fri Oct 25, 2013 4:41 pm

Hi,

I was trying to run the query with like operator but it showing zero rows
 FROM LPU@PDB.SGCPA93_FSA_VINPRE A
     ,LPU@PDB.SGCPA16_GLBFSAHUB B
 WHERE GCPA13_UPDATE_S LIKE '2013-10-18%'   AND A.GCPA15_GLOBL_FSA_R = B.GCPA15_GLOBL_FSA_R
   AND B.GCPA16_LAUNCH_Y > '2008-12-31'


Can you please advise any one on this
surime72
 
Posts: 107
Joined: Sun Oct 23, 2011 1:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Date in Db2

 

Re: Date in Db2

Postby Akatsukami » Fri Oct 25, 2013 4:45 pm

How is GCPA13_UPDATE_S defined?
"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: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Date in Db2

Postby NicC » Fri Oct 25, 2013 4:48 pm

Ys we can advise:
1 - give us more information. Your code, as shown, cannot find data to match the WHERE so, show us data that does match all 3 conditions
2 - you cannont include bbCode tags within code tags - I have removed them
3 - structure your query a bit better simply for clarity - code each AND on a separate line and indented from the WHERE
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Date in Db2

Postby surime72 » Fri Oct 25, 2013 4:55 pm

thanks for your reply GCPA13_UPDATE_S is defined as time stamp fileld
surime72
 
Posts: 107
Joined: Sun Oct 23, 2011 1:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Date in Db2

Postby Akatsukami » Fri Oct 25, 2013 5:06 pm

surime72 wrote:thanks for your reply GCPA13_UPDATE_S is defined as time stamp fileld

As the fine manual makes clear, LIKE only works with character fields. Use
DATE(GCPA13_UPDATE_S) = '2013-10-18'
"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: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Date in Db2

Postby surime72 » Fri Oct 25, 2013 8:12 pm

thanks it's working...


One more doubt in the same we need to extract the data for the date in 2013-10-19-00.29.45.898424 but it should not exceeds the time stamp 2013-10-19-00.59.45.898424

I need the data for 18-10-2013 data and < 2013-10-19-00.59.45.898424
surime72
 
Posts: 107
Joined: Sun Oct 23, 2011 1:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Date in Db2

Postby Akatsukami » Fri Oct 25, 2013 8:29 pm

Then simply code
WHERE DATE(GCPA13_UPDATE_S) >= '2013-10-18' AND
GCPA13_UPDATE_S < '2013-10-19-00.59.45.898424'

(and, of course, such additional conditions as you require).
"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: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post