how can I make a query filtering with date and time?

this way

SELECT * FROM TABLE
WHERE DATE_ORDER >= 07-02-2013 09:00  and DATE_ORDER  <= 07-02-2013 09:30


|Thanks
Alex
LVL 1
hidrauAsked:
Who is Participating?
 
bigbigpigConnect With a Mentor Commented:
select * from table where date_order between '07-02-2013 09:00' and '07-02-2013 09:30';
0
 
hidrauAuthor Commented:
I got this error
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.
0
 
bigbigpigCommented:
Your data type of DATE_ORDER is smalldatetime?

select * from table where date_order between CAST('07-02-2013 09:00' AS smalldatetime) and CAST('07-02-2013 09:30' AS smalldatetime);
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
0
 
Anthony PerkinsConnect With a Mentor Commented:
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value
Since you are using a character data type instead of datetime or smalldatetime you are going to have to:
1.  Fix all badly formatted data.
2.  When 1 is done, let us know what date format you are using.
0
 
hidrauAuthor Commented:
Thanks everybody
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.