Page 1 of 1
Date in Db2
Posted:
Fri Oct 25, 2013 4:41 pm
by surime72
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
Re: Date in Db2
Posted:
Fri Oct 25, 2013 4:45 pm
by Akatsukami
How is GCPA13_UPDATE_S defined?
Re: Date in Db2
Posted:
Fri Oct 25, 2013 4:48 pm
by NicC
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
Re: Date in Db2
Posted:
Fri Oct 25, 2013 4:55 pm
by surime72
thanks for your reply GCPA13_UPDATE_S is defined as time stamp fileld
Re: Date in Db2
Posted:
Fri Oct 25, 2013 5:06 pm
by Akatsukami
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'
Re: Date in Db2
Posted:
Fri Oct 25, 2013 8:12 pm
by surime72
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
Re: Date in Db2
Posted:
Fri Oct 25, 2013 8:29 pm
by Akatsukami
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).