Sunday, 30 June 2013

Sql Dynamic query using "between and operator" in sql for date comarison




        string strquery = "select ROW_NUMBER() OVER(ORDER BY s.TransactionDatatime DESC) AS SNo, s.session_Id,p.PolicyNumber,s.TransactionId,s.TransactionDatatime from ";
        strquery += strLOB;
        strquery += "session s inner join ";
        strquery += strLOB;
        strquery += "data d on s.session_Id=d.session_Id inner join ";
        strquery += strLOB;
        strquery += "policy p on d.data_Id=p.data_Id where DATEADD(D, 0, DATEDIFF(D, 0, s.TransactionDatatime)) between ";
        strquery += " " + "'" + strSdate + "'" + " and " + "'" + strEdate + "'";

No comments:

Post a Comment