• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

SQL Select Statement

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'
  • 3
2 Solutions
Aneesh RetnakaranDatabase AdministratorCommented:
select * from billing where cretedTime between  cast('6/7/2009' as datetime)  and cast( '7/7/2009' as datetime)
Which database is this?


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')

Once again, programming the "Unknown database" sort of like "The Tomb of the Unknown Soldier... "   :)
lemargeAuthor Commented:
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.
*wink* you too young Skywalker...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now