Discussion on:

Message 9 of 13
0 Votes
+ -
RE: 10 tips for working with dates in Microsoft Access
Hi,

SELECT e.EmpCode, e.DesiCode, e.EmpName, e.EmpAdd, e.BasicSalary, d.DesiName, e.JoiningDate, Format (e.JoiningDate, 'MM/yyyy'),format(e.RetierDate,"mm/yy"),e.RetierDate, Format (e.RetierDate, 'MM/yyyy'), (SELECT SUM(a.Amount) FROM pay_emp_master as e1 INNER JOIN pay_emp_allowances as a ON e1.EmpCode=a.EmpCode WHERE a.EmpCode=e.EmpCode GROUP BY e1.EmpCode,a.AllowCode) AS SumAllow, IIF([SumAllow],[SumAllow],0) AS SumAllow1, (SELECT SUM(d.Amount) FROM pay_emp_master as e1 INNER JOIN pay_emp_deductions as d ON e1.EmpCode=d.EmpCode WHERE d.EmpCode=e.EmpCode GROUP BY e1.EmpCode,d.DeductionCode) AS SumDeduct, IIF([SumDeduct],[SumDeduct],0) AS SumDeduct1
FROM pay_emp_master AS e INNER JOIN pay_desi_master AS d ON e.DesiCode=d.DesiCode
WHERE (e.EmpCode=17) And ((year(#02/2002#) between year(e.JoiningDate) and year(e.RetierDate)) AND (month(#02/2002#) >= month(e.JoiningDate) and month(#02/2002#)= month(e.RetierDate)));

As per above query I can check whether years of dates as well as months of dates is between the two dates or not.
But if my first date is '01/2002' (it is in the month/year format) & second date is '01,2004' (it is in the month/year format) & I wish to check whether '02/2002'is between '01/2002' & '01,2004' then above query is not fetching any records......so plz plz plz help me with this...it's urgent!!!!
Posted by nehabeke
10th Jan 2011