473,382 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Help needed querying data between two dates!!!!

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 7541
willakawill
1,646 1GB
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 Expert
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
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_Date'||'235959','MM/DD/YYYYHH24MISS')

Then you can define the start and end dates.
Nov 16 '06 #4
pragatiswain
96 Expert
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
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...
1
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...
2
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...
2
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
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...
0
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...
0
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...
1
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.