i have wrote this function for date...... used in daily cash accounting which is working perfectly, now i am going to develop monthwise cash accounting. can anyone please help me out how can i convert this date funtion to month.
DECLARE @OpeningAmt NUMERIC(19,2), @Pdate date
--return
SET @date= DATEADD(date, -1,@fromdate)
if (isnull(@FromDate, '1900-01-01') <> '1900-01-01')
begin
Declare @Opening table
(
TENDERTYPE int
, TenderName varchar(500)
, Opening numeric(19,2)
, NetSales decimal(28,2)
, DepositAmt numeric(19,2)
, ExpenseAmount numeric(19,2)
, Income numeric(19,2)
, Payments numeric(19,2)
)
insert into @Opening
EXEC [MtqRpt_TenderTotalsDynamic]
@PDataAreaID = @PDataAreaID,
@StoreId = @StoreId,
@FromDate = <10900-01-01>
@ToDate = @Pdate
@Terminal = @Terminal
select @OpeningAmt = sum( NetSales + Income - (DepositAmt + ExpenseAmount ) )
from @Opening
where TENDERTYPE = 1
end