Get Current Month Total Sales Using SQL Query or Store procedure, get Today Date from SQL , Get first Day of the Month
CREATE PROCEDURE [dbo].[GetSalesbyMonthly]
AS
BEGIN
DECLARE @Today DATE;
DECLARE @FirstDay DATE;
/*Get First Day And Month And into @FirstDay Variable */
/*Get First Day And Month And into @FirstDay Variable */
SET @FirstDay= (select dateadd(dd,-(day(getdate())-1),getdate()) )
/*Get Today And Store into @Today Variable */
/*Get Today And Store into @Today Variable */
SET @Today= (SELECT CONVERT(DATE,GETDATE()) AS Today)
BEGIN
SELECT ISNULL(SUM([TotalSale]),0) AS TotalSales FROM YOURSALE
TABLE WHERE (DATE-COLUMN BETWEEN @FirstDay AND @Today)
END
END
Comments