find the total sum between two dates
The reason why you are unable to get the data between two dates is the way you have used the date parameters. You need to
pass it as DateTime fields instead of a string and change
query based on Datetime operation.
Changes needed:
1. Pass dates as DateTime parameters to SP
2. Change SP query to handle it as DateTime and then WHERE clause based on it.
Something like:
SqlParameter pStartDate = new SqlParameter("@STARTDATE", SqlDbType.DateTime);
SqlParameter pEndDate = new SqlParameter("@ENDDATE", SqlDbType.DateTime);
pStartDate.Value = Convert.ToDateTime(StartDate);
pEndDate.Value = Convert.ToDateTime(StartDate2);
Refer:
MSDN: SqlDbType Enumeration[
^]
Change query to (assuming tDateofJourney is defined as Date feild in DB, if not define it):
SELECT * from tblTicketing where tDateofJourney BETWEEN @STARTDATE and @ENDDATE
Refer:
MSDN: BETWEEN (Transact-SQL)[
^]