Solved

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

Posted on 2013-02-07
6
125 Views
Last Modified: 2013-02-08
this way

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


|Thanks
Alex
0
Comment
Question by:hidrau
6 Comments
 
LVL 10

Accepted Solution

by:
bigbigpig earned 167 total points
Comment Utility
select * from table where date_order between '07-02-2013 09:00' and '07-02-2013 09:30';
0
 
LVL 1

Author Comment

by:hidrau
Comment Utility
I got this error
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.
0
 
LVL 10

Expert Comment

by:bigbigpig
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 167 total points
Comment Utility
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 166 total points
Comment Utility
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
 
LVL 1

Author Closing Comment

by:hidrau
Comment Utility
Thanks everybody
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now