I have a DATETIME column "EntryDate" and I am storing values as dd/MM/yyyy format. But when I fetch records through SQL I don't get the expected result.
For ex:
I have 90 records from date 23/10/2009 to 23/11/2009. I get only 5-10 records. Why is this ?
Here is my query :
SET DATEFORMAT DMY;
SELECT * FROM salesorderlist so
LEFT JOINT sites s ON s.id = so.siteid
WHERE so.entrydate between '23/10/2009' and '23/11/2009'
ORDER BY so.entryDate DESC
But when I give date range from 23/10/2009 to 31/10/2009 I get the correct result, and if I give date range from 23/10/2009 to 01/11/2009 I don't get even a single row.
What am I missing ?
In database I am storing values as "31/10/2009" (dd/MM/yyyy) format.
Thanks in advance.
Have done a blunder..
Entrydate is Varchar Column. Now changed it to Datetime.Thanks Guys for your help
I have a bigger problem now...How do i convert varchar column to datetime column...how to update the table
When i try to change the datatype i get the error: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated.
I dont want to delete records as there are thousands of records.Is there any way to convert ? Thanks