Solved

sql query between not working

Posted on 2011-09-02
3
143 Views
Last Modified: 2012-05-12
Hello experts,
I am working with sql server 2005.
I am trying to execute a query like  "SELECT username,date, convert(datetime, actionDate,3)  FROM logs WHERE ID>0" and that is working fine.

when i try it with  "SELECT username,date, convert(datetime, actionDate,103)  FROM logs WHERE convert(datetime, actionDate,103)  > '01/06/2010'" then i get an error.

i get error for the between statement also.
The records exist in the database.
Where do i missing something here?
Thanks in advance.
0
Comment
Question by:Ludo_Dirckx
3 Comments
 
LVL 5

Expert Comment

by:DavidMorrison
ID: 36472273
Hi,
What error do you get?
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 36472314
it's time to read this article:
http://www.experts-exchange.com/A_1499.html

in short:
>convert(datetime, actionDate,103)  > '01/06/2010'
is actiondate a date field or a text field?
if it's date:
actionDate > convert(datetime,  '01/06/2010' ,103)  

if it's text:
convert(datetime, actionDate,103) > convert(datetime,  '01/06/2010' ,103)  

hope this helps
0
 

Author Comment

by:Ludo_Dirckx
ID: 36472425
Hi Experts,
Thanks for the current reply.
Angelll - you got correct, thanks.
It is a date field and working perfect.
Even i changed the query to  
 Dim rdrQuery As String = "SELECT * FROM logs WHERE actionDate between convert(datetime,  '29/06/2011' ,103) and convert(datetime,  '29/07/2011' ,103) "
It is working.

Thanks a lot.
Have a nice day.


0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Query 2 61
SQl Agent job fails--SSIS package looses password 6 46
How to use TOP 1 in a T-SQL sub-query? 14 44
SQL Server 2005 - Comparing Fields' Contents 6 31
Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

815 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

12 Experts available now in Live!

Get 1:1 Help Now