Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi in my tblCurrencySale contains csProfit and csDate..so now i want to calculate total profit
like in my aspx page two dropdowns r der its only date..
so now i want to calculate profit between two dates
like 5/18/2012 and 5/30/2012 when i click search should display total profit in text box..can u suggest me how to give sp and call it in aspx.cs page??

thanks
Posted
Updated 17-May-12 19:39pm
v2
Comments
Oshtri Deka 18-May-12 8:38am    
Can you please, at least in future, try to use punctuation and capital letters.
It is hard to read poorly written questions.

Basically the SQL could be something like
SQL
SELECT SUM(csProfit)
FROM tblCurrencySale
WHERE  csDate BETWEEN @startdate AND @enddate

And to execute the statement you can use SqlCommand[^]
 
Share this answer
 
create PROCEDURE usp_CurrencyProfit
 @STARTDATE datetime,
 @ENDDATE   datetime
AS
        BEGIN
        SET NOCOUNT ON;

        SELECT ISNULL( SUM ( csProfit ) , 0 )
        FROM tblCurrencySale
        WHERE csDate BETWEEN  @STARTDATE   AND    @ENDDATE       
        END
GO
 
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