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

Raju KatarePosted Feb 8, 2011, 11:46 PM
Let me know that have you got the output?
Suthish NairPosted Feb 8, 2011, 1:33 PM
Raju KatarePosted Feb 8, 2011, 12:49 AM
Hi Markand
use following query you will get desired result
SELECT * FROM mytable WHERE
convert(varchar,dtcreated,112)>=convert(varchar,fromdate ,112)
AND
convert(varchar,dtcreated,112)<=convert(varchar,todate,112)
Suthish NairPosted Feb 7, 2011, 2:28 PM