Here is a stored procedure that returns records between from date and to date by ignoring their time values. If the from date , to date are not supplied it returns all the values of the table.
CREATE Procedure [dbo].getAllRecordsIgnoringTimevalues ( @FromDate VARCHAR(25) =NULL,--indicates that the parameter it is optional @ToDate VARCHAR(25) =NULL --indicates that the parameter it is optional ) As Begin Select * From [dbo].tabletosearch WHERE AND (CAST(FLOOR(CAST( fromdate AS float)) AS datetime) >= convert(datetime,@FromDate)OR ISNULL(convert(datetime,@FromDate),'')='') AND (CAST(FLOOR(CAST( todate AS float)) AS datetime) <= convert(datetime,@ToDate) OR ISNULL(convert(datetime,@ToDate),'')='') END
|
No responses found. Be the first to respond and make money from revenue sharing program.
|