4
Answers

Get Records between two dates in MS SQL

MARKAND BHATT

MARKAND BHATT

13y
6k
1
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)