Simple date range in sql server 2005

I have the following query:

select transassgndate from remarketing
where transassgndate >= '10/1/2009' and transassgndate <= '11/5/2009'

Why does this query return rows with dates in the year 2008?
ipamanAsked:
Who is Participating?
 
pcelbaCommented:

select transassgndate from remarketing
where transassgndate BETWEEN convert(datetime,  '10/1/2009', 101) and convert(datetime, '11/5/2009', 101)
0
 
leakim971PluritechnicianCommented:
Hello,

The date format is not correct.
Could you confirm : MM/DD/YYYY

Regards.

Try :


select transassgndate from remarketing where transassgndate >= '01/10/2009' and transassgndate <= '05/11/2009'

Open in new window

0
 
ipamanAuthor Commented:
yes, for some reason the column type is a varchar. should be a datetime type.

How can I compare dates (like I am trying to do above) if the column type is varchar?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.