473,587 Members | 2,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help needed querying data between two dates!!!!

12 New Member
Probably a simple solution but can't find it myself can someone help?????
I would like to extract data from a table where the dates
are between two dates and then loop to select more data for another two sets of dates.

At the moment I have done this select statement


select *
from table_name
where
and date_field between '24-OCT-2005' and '26-OCT-2006'

I have also indexed the date field so that the query response will be quicker
and not cause rollback segment errors.


Please can someone help?
Nov 14 '06 #1
4 7548
willakawill
1,646 Top Contributor
Probably a simple solution but can't find it myself can someone help?????
I would like to extract data from a table where the dates
are between two dates and then loop to select more data for another two sets of dates.

At the moment I have done this select statement


select *
from table_name
where
and date_field between '24-OCT-2005' and '26-OCT-2006'

I have also indexed the date field so that the query response will be quicker
and not cause rollback segment errors.


Please can someone help?
Hi. Looks like you have one 'and' too many in this query otherwise you are good to go.

you can check this out here
Nov 14 '06 #2
pragatiswain
96 Recognized Expert New Member
If you want to have a single resultset, you can form a Dynamic query and execute.

select * from table_name
where date_field between '24-OCT-2005' and '26-OCT-2006'
and date_field between @StartDate1 and @EndDate1
and date_field between @StartDate2 and @EndDate2
.....
Hope this helps.
Nov 16 '06 #3
danibecr
18 New Member
What about something like this

DEFINE Begin_Date = "&BeginDate "
DEFINE End_Date = "&EndDate"

Select *
FROM ####
WHERE #####
BETWEEN TO_DATE('&Begin _Date'||'000000 ','MM/DD/YYYYHH24MISS')
AND TO_DATE('&End_D ate'||'235959', 'MM/DD/YYYYHH24MISS')

Then you can define the start and end dates.
Nov 16 '06 #4
pragatiswain
96 Recognized Expert New Member
Hi danibecr,

My Assumption: Actual data in database in that Date field is only dates without timepart as the example was

select *
from table_name
where
and date_field between '24-OCT-2005' and '26-OCT-2006'

Otherwise,
I would have stated
Select * FROM ####
WHERE TRUNC(#####) BETWEEN @Begin_Date AND @End_Date

One TRUNC() function is faster than execution of (||)String concatination function twice and execution of To_date() function twice.
Nov 16 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2664
by: Jack Smith | last post by:
Help needed on this question. Any help is appreciated. Thanks in advance. Given a binary string (i.e. a finite sequence of 0's and 1's) we choose any two digit substring 01 and replace it by a string of the form 100...0 using an arbitrary (but finite) number of zeros. Prove by induction that this transformation can not be performed...
1
1971
by: worzel | last post by:
Hi All, I am looking for a reg ex that will match email addresses withing <a href=mailto blah > links. Actually, I already crafted my own, but with a slight problem: <a href="mailto:fred@blah.com"> emal me</a> woud be matched as expected, but so will:
2
2408
by: Douglas | last post by:
Can somone help me contruct a simple query Basically I want my query to extract records where the MOT_Due_Date is between the 1st Day of the current month and the date 6 weeks from the 1st day of the current month. My MOT_Due_Day field is in the format "dd<space>mmm" ie 08 Jun and is a text field, not a date field i.e.
2
1479
by: Willie | last post by:
I try to setup SQL Server to work with .NET Framework Anyone here willing to help? Step By Step Help Needed. Thanks
8
1677
by: rh0dium | last post by:
Hi all, I am using python to drive another tool using pexpect. The values which I get back I would like to automatically put into a list if there is more than one return value. They provide me a way to see that the data is in set by parenthesising it. This is all generated as I said using pexpect - Here is how I use it.. child =...
0
1468
by: sgsiaokia | last post by:
I need help in extracting data from another source file using VBA. I have problems copying the extracted data and format into the required data format. And also, how do i delete the row that is not required in the output file, in the below example: The row, D0, is not needed. An Example Data Format From the SOURCE file: ...
0
2572
by: Christopher | last post by:
Urgent Help Needed: The EPVH-1.1 Visual Hull Library. Dear All, I am a student doing research in computer vision. The EPVH-1.1 Visual Hull Library will really help a lot in my research. I did have this library before but I didn't keep my copy of this library because I always thought I could download it again form internet. However, the...
1
2610
by: Joel Fireman | last post by:
Help Needed: Upgrade Fedora 4 / Apache 2 to PHP 5.2.x from 5.0.4 I've been testing Joomla as a content manager for the County offices, and it looks pretty good. Unfortunately, I decided to upgrade it from the 1.0.13 version to 1.5 as we get ready to go live with the web site... and the update installation gives an error in XML processing,...
1
1275
by: mik357 | last post by:
Hello all, I just started using SQL to create a report. I got the syntax working but I have absolutely no idea of how to format data. Can anyone kindly look at my code and help me? I thank you in advance. Details:- The code:
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.