Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-02-07
6
Medium Priority
?
135 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 668 total points
ID: 38864862
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
ID: 38864896
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
ID: 38864916
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 668 total points
ID: 38864939
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 664 total points
ID: 38866434
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
ID: 38868699
Thanks everybody
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .

879 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