shaileshpatil
05-07-2009, 08:10 AM
Hello
I am using MSSQL 2205.
In one of my query, i get different dates. I want to use the month and year in another query. I am creating stored procedure. How can i use it.
FE:
SELECT * from
(
select empid, empname, joindate
from employee
where <conditions>
order by joindate
) employee
WHERE NOT EXISTS (
SELECT * from Audit_T
WHERE empid=employee.empid and date between <how to use joindate here ? >)
-- It returns:
empid empname joindate
1 a 01-01-07
2 b 15-04-07
3 c 10-02-08
I want to use month and date of joindate date to query in another table using between clause
01-01-07 and 31-01-07
01-04-07 and 30-04-07 etc...
How this can be achieved
I am using MSSQL 2205.
In one of my query, i get different dates. I want to use the month and year in another query. I am creating stored procedure. How can i use it.
FE:
SELECT * from
(
select empid, empname, joindate
from employee
where <conditions>
order by joindate
) employee
WHERE NOT EXISTS (
SELECT * from Audit_T
WHERE empid=employee.empid and date between <how to use joindate here ? >)
-- It returns:
empid empname joindate
1 a 01-01-07
2 b 15-04-07
3 c 10-02-08
I want to use month and date of joindate date to query in another table using between clause
01-01-07 and 31-01-07
01-04-07 and 30-04-07 etc...
How this can be achieved