Click here to Skip to main content
15,896,402 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
SQL
ALTER PROCEDURE [dbo].[DailySummary] 
	-- Add the parameters for the stored procedure here
	@StartDate datetime = null,
	@RegionCode varchar(30) = null
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	
--Declare @DateA datetime 
--set @DateA=dateadd(hour,00,@StartDate)

Declare @DateB datetime
set @DateB = convert(datetime, convert(Varchar(12), @StartDate, 106) + ' 23:59:59PM')
--set @DateB = DATEADD(minute, txn.59, txn.@StartDate)
--set @DateB = DATEADD(SECOND, txn.59, txn.@StartDate)

	SET NOCOUNT ON;

    -- Insert statements for procedure here
	select distinct txn.Source_GpoName as GPO_Name,count(MoNo) as Total_EMO,Sum(Amount) as EMO_Value , sum(Commision) as Commission,Sum(Amount+ Commision)as Total_Amount
	from  MOTxn txn
	INNER JOIN AllPostOffice AS po ON txn.Source_GpoName = po.Name
	 where EntryDate between --( DATEDIFF(d,@StartDate,MOTxn_txn.EntryDate ) >= 0
  --  AND DATEDIFF(d,@DateB,MOTxn_txn.EntryDate)<= 0) 
   @StartDate and @DateB   
	 
	  --convert(date,@StartDate) AND convert(date,DateADD(dd,1,@EndDate))
	  --convert(date,@StartDate) AND convert(date,DateADD(dd,1,@DateB))


	--WHERE  EntryDate Between ( DATEDIFF(d,@StartDate,MOTxn_txn.EntryDate ) >= 0
 --AND DATEDIFF(d,@DateB,MOTxn_txn.EntryDate)<= 0)
 --AND ( EntryDate <> 0 )        
	--and isPaid='0'

	and po.RegionCode LIKE  ISNULL(@RegionCode ,'') + '%'
	group by Source_GpoName
END
Posted
Updated 7-Dec-15 21:11pm
v3

Hi,

Add below query where you added date where condtion

SQL
WHERE DATEDIFF(d,@startDate,vv_TxnTemp.CreatedOn ) >= 0
			  AND DATEDIFF(d,@endDate2,vv_TxnTemp.CreatedOn)<= 0
 
Share this answer
 
SQL
@StartDate date
where cast(EntryDate as date) = @StartDate 
 
Share this answer
 
I have solved my issue
it is

BETWEEN @STARTDATE and @ENDDATE
 
Share this answer
 

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