SQL Server - start to date, start to month cummulative

Asked By farrukh on 30-Nov-11 05:33 AM
Hi all,

 i need a function or procedure that calculate the start to date (cumulative) of data  and start to month cumulative . or for  start to month it runs on the last date of month and calculate the sum.


any help would be appreciate , i am new to sql server and want to create a report.


thanks
faraz
Chintan Vaghela replied to farrukh on 30-Nov-11 05:49 AM

Hello

 

Try sql query as follows

 

Declare @FromDate as DateTime='2011-04-01'

  Declare @ToDate as DateTime='2011-11-30'

Select * from TableName where CONVERT(Varchar,DateFiled,102) between CONVERT(Varchar,@FromDate,102) and CONVERT(Varchar,@ToDate,102)

 

 

Added above query in sp and call this SP in report then you achieve your task.

farrukh replied to Chintan Vaghela on 11-Dec-11 10:18 AM
HI RB,

THANK YOU SO MUCH IT WORKS FOR ME...

THANKS
HAMMEED
Chintan Vaghela replied to farrukh on 12-Dec-11 01:03 AM
You most welcome