hi,i am using like this to find sl leave,pl leave and lossofpay(lop)leave....
cmd = New SqlCommand("select sum(sl) from leavedepot where empcode like '" + Label4.Text + "'", connection)
cmd = New SqlCommand("select sum(pl) from leavedepot where empcode like '" + Label4.Text + "'", connection)
cmd = New SqlCommand("select sum(lop) from leavedepot where empcode like '" + Label4.Text + "'and month like'" + DropDownList2.Text + "'", connection)
this is your query ,i dont no how to execute in my program..actually in my payslip generation web form i am having lot of controls.the first control is to select the employee id,if the employee id is selected and the user is allowed to select the date from date in textbox1 and to date in textbox2,if 1st january to 31 january,as per the values,the total sl,pl,lop will be displayed in the respective textbox,,,how can i pass the textbox1 datevalue and textbox2 datevalue to this stored procedure
declare @tdate as datetime
declare @fdate as datetime
declare @monthdiff as int
set @fdate = '2012-01-25'
set @tdate = '2012-02-03'
set @monthdiff = DATEDIFF(mm,@fdate,@tdate)
Select DATEDIFF(dd,@fdate,@tdate)'Total Days',
Case
When @monthdiff>0 Then DATEDIFF(d,@fdate, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,@fdate)+1,0)))
When @monthdiff=0 Then DATEDIFF(d,@fdate,@tdate)
END as 'DaysInMonth'
Mohamed Rifayee
Rifayeem, if this helps please login to Mark As Answer. | Alert Moderator