var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: How to dis play previous month(Dec) details in db2
Please help me for the following problem in db2.
In employee table i want to show the previous month salaray details...but i run this query every month 1st.
select * from employee where year(salary_date)=year(current timestamp) and month(salary_date)=month(current timestamp)-1;
but here i faced one problem is
i want to run this query January month of current year...this time i want to display Last year December ,2010 details.
if i want to run this curent year after february the above query working fine
if a run this after feburay the above query get the jan month details.
pls help for above query.
Last edited by nsrinusetty; 07-08-11 at 03:20.
Reason: i need more information
Apply YEAR and MONTH functions after subtracting 1 month from current date.
Example: Because you are iquiring salary_date, using current date would be enough.
select * from employee
where year (salary_date) = year (current date - 1 month)
and month(salary_date) = month(current date - 1 month)
BETWEEN LAST_DAY(current date - 2 MONTH) + 1 DAY /* first day of previous month */
AND current date - DAY(current date) DAYs /* last day of previous month */
Last edited by tonkuma; 07-08-11 at 02:54.
Reason: Add comments to second example.