Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,

Please Have a look at the parameters that I am passing to the DashBoard stored proc. Its working fine when I pass the parameter as date, but I need it to be working when I pass the parameter for both date and time.
e.g., ALTER proc [dbo].[DashBoardTime] '01/01/2011 9:00:00 AM','01/25/2011 10:00:00 PM'

USE [FTA]
GO
/****** Object:  StoredProcedure [dbo].[DashBoard]    Script Date: 02/02/2011 11:20:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER proc [dbo].[DashBoard] --'01/01/2011','01/25/2011'
(
@startdate datetime,
@enddate datetime
)
as
begin
set nocount on
DECLARE @temptable TABLE
(
HubId BIGINT,
HubName NVARCHAR(50),
InwardPass BIGINT,
InwardFail BIGINT
)
INSERT INTO @temptable(HubId,HubName)
--SELECT 0  AS 'HUBId','Total' AS 'HubName' UNION 
SELECT DISTINCT HUBId,HubName FROM tbl_DataHubView WHERE IsActive=1 

UPDATE @temptable SET InwardPass = 
(select COUNT(InwardID)  FROM tbl_Inward A WHERE A.iDataHubID=B.HubId AND InwardStatus='Accept' AND Convert(VARCHAR(50),InwardUpdateTime,101) between Convert(VARCHAR(50),@startdate,101) AND Convert(VARCHAR(50),@enddate,101))
FROM @temptable B
UPDATE @temptable SET InwardFail = 
(select COUNT(InwardID)  FROM tbl_Inward A WHERE A.iDataHubID=B.HubId AND InwardStatus='Reject' AND Convert(VARCHAR(50),InwardUpdateTime,101) between Convert(VARCHAR(50),@startdate,101) AND Convert(VARCHAR(50),@enddate,101))
FROM @temptable B


INSERT INTO @temptable(HubId,HubName,InwardPass,InwardFail)
SELECT 0  AS 'HUBId','Total' AS 'HubName',SUM(InwardPass) AS 'InwardPass',SUM(InwardFail) AS 'InwardFail'
FROM @temptable
select HubName,InwardPass,InwardFail FROM @temptable
end




Can Anyone Help me in this?

Thanks in advance.

Raj
Posted
Updated 1-Feb-11 19:22pm
v2

1 solution

Please check the example:
<pre lang="sql">Create proc [dbo].[DashBoard] (@startdate datetime,@enddate datetime)
as
begin
DECLARE @temptable TABLE (mystartdate datetime, myEnddate datetime )
insert into @temptable (mystartdate, myEnddate) values (@startdate , @enddate)
select * FROM @temptable
end
go

exec Dashboard '01/01/2011 9:00:00 AM','01/25/2011 10:00:00 PM'

 
Share this answer
 
Comments
Raj.rcr 2-Feb-11 2:42am    
No. There is a conversion from nvarchar to datetime using "convert" keyword in sql. I have got the answer few minutes ago.. Anyways, thanx so much for ur reply.

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