Solved

sql query between not working

Posted on 2011-09-02
3
145 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 143

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 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