Your command string is wrong:
SELECT * FROM @Tablename WHERE Created_On >= '@StartDate' AND Created_On <= '@EndDate';
Does not include the parameter values for
@StartDate
and
@EndDate
in the eventual query, in includes the literal strings
'@StartDate'
and
'@EndDate'
in the string.
Try taking off the quotes and see what happens then:
SELECT * FROM @Tablename WHERE Created_On >= @StartDate AND Created_On <= @EndDate;
But ... don't store dates in string form: they are very prone to errors. If your DB contains the string date "01-02-03" did the user who entered it mean "1st Feb 2003", "2nd Jan 2003", or "3rd Feb 2001"? They are all valid interpretations of that date.
And it gets worse when you want to compare dates: string comparisons are always done character by character and the result of the comparison if based on the first difference in characters. So depending on what format the data is entered in will determine the sort order. And worse, that's assuming the date isn't entered with a month name instead of a number, and that it's not been entered by a French or German person!
Always store information in the most appropriate variable type: INT, DECIMAL, or FLOAT for numbers, DATE, DATETIME, or DATETIME2 for dates and timestamps.