Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello friends,
Myself Prashant, I want to create
report for monthly basis.

I have created StoredProcedure which takes date, I want to pass days of month in loop to this SP.
Can anyone help me to know how to carry out this task, I'm really confused.

Thanks in advance
Posted

1 solution

 
Share this answer
 
Comments
dhage.prashant01 9-Dec-10 7:26am    
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
DECLARE @ChkDate DATETIME

SET @StartDate = '1/10/2010'
SET @EndDate = '31/10/2010'
SET @ChkDate = '1/10/2010'

WHILE @ChkDate <= @EndDate
BEGIN
select MAX(actiondate) from tbl_action_history A
left outer join tbl_mechanicalbrief M on M.jobno = A.jobno and M.artworktype=1
left outer join tbl_iteration I on I.jobno=A.jobno and I.artworktype=2
where actionstatus in (55,56,20,33) and (actiondate between convert(datetime,''' + @ChkDate + '' 00:00:01.613',110) and convert(datetime,''' + @ChkDate + '' 23:59:59.613',110)) and A.jobtype not in (3,4,5,6,7,8)
END

OUTPUT:
Error: Conversion failed when converting date and/or time from character string.

-------------
How should proceed further. Please need solution
Toniyo Jackson 9-Dec-10 7:30am    
Try this,
BEGIN
select MAX(actiondate) from tbl_action_history A
left outer join tbl_mechanicalbrief M on M.jobno = A.jobno and M.artworktype=1
left outer join tbl_iteration I on I.jobno=A.jobno and I.artworktype=2
where actionstatus in (55,56,20,33) and actiondate = @ChkDate and A.jobtype not in (3,4,5,6,7,8)
END
Toniyo Jackson 9-Dec-10 7:37am    
Yes. Of course. Vote and accept the answer if its working.
dhage.prashant01 9-Dec-10 7:48am    
I have tried your Solution, its giving me NULL output

I want to get last action time the QC head has taken in that day, so m using MAX(actiondate)
Toniyo Jackson 9-Dec-10 7:50am    
Try only using the main table,
select MAX(actiondate) from tbl_action_history
where actiondate = @ChkDate

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900