Solved

SQL Select Statement

Posted on 2009-07-07
5
179 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
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.​
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

19 Experts available now in Live!

Get 1:1 Help Now