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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
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
All Courses

From novice to tech pro — start learning today.