Solved

SQL Select Statement

Posted on 2009-07-07
5
216 Views
Last Modified: 2012-05-07
Hello Experts.
I have to fields which are varchar but contain dates.
I would like to do a between clause but i think that i should convert the strings to dates to ensure i am getting the correct values returned. Will you please provide some direction as to how this can be done. Thanks in advance for your assistance


select * from billing where cretedTime between '6/7/2009' and '7/7/2009'
0
Comment
Question by:lemarge
[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
  • 3
5 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 250 total points
ID: 24800076
select * from billing where cretedTime between  cast('6/7/2009' as datetime)  and cast( '7/7/2009' as datetime)
0
 
LVL 40

Assisted Solution

by:mrjoltcola
mrjoltcola earned 250 total points
ID: 24800142
Which database is this?

Oracle:

select * from billing
  where TO_DATE(cretedTime, 'MM/DD/YYYY') between TO_DATE('6/7/2009', 'MM/DD/YYYY') and TO_DATE('7/7/2009', 'MM/DD/YYYY')

0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24800213
Once again, programming the "Unknown database" sort of like "The Tomb of the Unknown Soldier... "   :)
0
 

Author Comment

by:lemarge
ID: 24800224
i am sorry i will append the database next time. By the way it was SQL Server.. hay dont you sleep..
Have a good night Master Yoda.
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24800285
*wink* you too young Skywalker...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

690 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