Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get current month and current year data from DB2 table

Status
Not open for further replies.

rulala

Programmer
Sep 19, 2009
1
US
Hello. Please help as this is urgent. I have a DB2 table where I need to get the current month and year from table X. gl_date is defined as date and is 10 bytes. Here is the query I used. It works if I use the month or the year but not both. Thank you.

select *
from table x
where month(gl_date) = month(current date)
and year(gl_date) = year(current date);

 
Hi rulala,
The query looks ok to me, but maybe I have misunderstood what you are asking for.

Could you possibly show some data on table x with the results that you are expecting. That way we will know exactly what you are after.

Regards,

Marc
 



Hi,
It works if I use the month or the year but not both. Thank you.
HUH???
Code:
where month(gl_date) = month(current date)
[b]and[/b] year(gl_date) = year(current date);
Is that not exactly what you have???

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top