How do I make a query?

G

Guest

I have a field stating start date and I have a field stating end date in a
table. I want to pull the fiscal year records. My problem is that some
start dates are not in the fiscal year but the end date is, visversa. Ex.
start date 02/05/05 and end date 09/02/07 and I want all records that fall
in the fiscal year from 07/01/2005 to 06/30/2006, which this record would,
but I don't know how to pull it. I tried Between [Enter Start Date] And
[Enter End Date] as the criteria in the Start Date field; however, if the
start date is not in the criteria but the end date is then the record is not
pulled. I don't know how to combine the two fields. Does this make sense?
Please help.
 
R

Rick B

Use that criteria on BOTH the start date and end date.

Put the criteria on two separate lines in your query grid to create an *or*
condition.


Under The "StartDate" field in your query, put your criteria as:
Between [Enter Start Date] And [Enter End Date]

Then under the "EndDate" field in your query (but on the next row) put the
same criteria:
Between [Enter Start Date] And [Enter End Date]


This should find any records where the start date is in the time period *or*
the end date is within the time period.

Hope that helps,
 
G

Guest

Oh MY GOSH! I can't believe the answer was THAT simple! I was so close to
figuring it out! Thank you!

Rick B said:
Use that criteria on BOTH the start date and end date.

Put the criteria on two separate lines in your query grid to create an *or*
condition.


Under The "StartDate" field in your query, put your criteria as:
Between [Enter Start Date] And [Enter End Date]

Then under the "EndDate" field in your query (but on the next row) put the
same criteria:
Between [Enter Start Date] And [Enter End Date]


This should find any records where the start date is in the time period *or*
the end date is within the time period.

Hope that helps,
--
Rick B



Jinny said:
I have a field stating start date and I have a field stating end date in a
table. I want to pull the fiscal year records. My problem is that some
start dates are not in the fiscal year but the end date is, visversa. Ex.
start date 02/05/05 and end date 09/02/07 and I want all records that
fall
in the fiscal year from 07/01/2005 to 06/30/2006, which this record would,
but I don't know how to pull it. I tried Between [Enter Start Date] And
[Enter End Date] as the criteria in the Start Date field; however, if the
start date is not in the criteria but the end date is then the record is
not
pulled. I don't know how to combine the two fields. Does this make
sense?
Please help.
 
J

John Spencer

That looks as if it should work. One problem is if the start date is before
the beginning of the period and the end date is after the end of the
period - in that case you still would not get the record.


To get this you could use
SELECT ...
FROM ...
WHERE [StartDate] <= [Enter end date of Period] and [EndDate] >=[Enter
start date of period]


In the query grid:
Field: StartDate
Critieria: <= [Enter end date of Period]

Field: EndDate
Criteria: >=[Enter start date of period]


Rick B said:
Use that criteria on BOTH the start date and end date.

Put the criteria on two separate lines in your query grid to create an
*or* condition.


Under The "StartDate" field in your query, put your criteria as:
Between [Enter Start Date] And [Enter End Date]

Then under the "EndDate" field in your query (but on the next row) put the
same criteria:
Between [Enter Start Date] And [Enter End Date]


This should find any records where the start date is in the time period
*or* the end date is within the time period.

Hope that helps,
--
Rick B



Jinny said:
I have a field stating start date and I have a field stating end date in a
table. I want to pull the fiscal year records. My problem is that some
start dates are not in the fiscal year but the end date is, visversa.
Ex.
start date 02/05/05 and end date 09/02/07 and I want all records that
fall
in the fiscal year from 07/01/2005 to 06/30/2006, which this record
would,
but I don't know how to pull it. I tried Between [Enter Start Date] And
[Enter End Date] as the criteria in the Start Date field; however, if the
start date is not in the criteria but the end date is then the record is
not
pulled. I don't know how to combine the two fields. Does this make
sense?
Please help.
 
R

Rick B

Oooh good point, John!


--
Rick B



John Spencer said:
That looks as if it should work. One problem is if the start date is
before the beginning of the period and the end date is after the end of
the period - in that case you still would not get the record.


To get this you could use
SELECT ...
FROM ...
WHERE [StartDate] <= [Enter end date of Period] and [EndDate] >=[Enter
start date of period]


In the query grid:
Field: StartDate
Critieria: <= [Enter end date of Period]

Field: EndDate
Criteria: >=[Enter start date of period]


Rick B said:
Use that criteria on BOTH the start date and end date.

Put the criteria on two separate lines in your query grid to create an
*or* condition.


Under The "StartDate" field in your query, put your criteria as:
Between [Enter Start Date] And [Enter End Date]

Then under the "EndDate" field in your query (but on the next row) put
the same criteria:
Between [Enter Start Date] And [Enter End Date]


This should find any records where the start date is in the time period
*or* the end date is within the time period.

Hope that helps,
--
Rick B



Jinny said:
I have a field stating start date and I have a field stating end date in
a
table. I want to pull the fiscal year records. My problem is that some
start dates are not in the fiscal year but the end date is, visversa.
Ex.
start date 02/05/05 and end date 09/02/07 and I want all records that
fall
in the fiscal year from 07/01/2005 to 06/30/2006, which this record
would,
but I don't know how to pull it. I tried Between [Enter Start Date] And
[Enter End Date] as the criteria in the Start Date field; however, if
the
start date is not in the criteria but the end date is then the record is
not
pulled. I don't know how to combine the two fields. Does this make
sense?
Please help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top