yyyy-mmm-dd to dd/mm/yyyy

orders.dateordered is datatime in the form yyyy-mm-dd
2010-01-01 18:04:14.000
2009-12-29 06:11:22.000
2010-01-02 05:55:21.000

$date1 is 31/01/2010  dd/mm/yyyy
select * from orders where dateordered is between $date1 and $date2

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:

select * from orders where dateordered  CONVERT(DATETIME, @Date1,103) AND CONVERT(DATETIME, @Date2,103)
always supply your dates as YYYYMMDD and you wont have any problems,,,


select * from orders
where dateordered between '20100405 00:00:00.000'
   and '20100506 23:59:59.999'


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgb192Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.