Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Simple date range in sql server 2005

Posted on 2009-12-29
3
Medium Priority
?
279 Views
Last Modified: 2012-05-08
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?
0
Comment
Question by:ipaman
3 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 26140200
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
 

Author Comment

by:ipaman
ID: 26140262
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
 
LVL 43

Accepted Solution

by:
pcelba earned 200 total points
ID: 26140314

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question