Solved

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

Posted on 2013-02-07
6
130 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 10

Accepted Solution

by:
bigbigpig earned 167 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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 
LVL 143

Assisted Solution

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

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 166 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 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