MARKAND BHATT

MARKAND BHATT

  • NA
  • 3
  • 19.7k

Get Records between two dates in MS SQL

Feb 7 2011 12:56 PM
I have a table in which i have a column named "dtCreated" which has got datatype as VARCHAR(50)

Now I want records between two dates.

I wrote my query as written below

SELECT * FROM mytable WHERE dtcreated>=fromdate AND dtcreated<=todate


This query work fine when fromdate and ToDate are of same month. i.e if fromDate =1/1/2011
and todate is 1/31/2011 it will work fine

But if fromdate is 1/1/2011 and todate is 2/1/2011 then no records will be returned.

Please give me solution of it

Answers (4)