Querying dates between two tables

F

Freeman girl

I have a query that has multiple columns with dates. I need to be able to
query one column against another column. Is that possile?

Example: Column A has an admission date to a hospitalization
Column B has an authorization date.

I need for my query to only pull hospitalizations (column A) that occurred
after authorizations were issued (column B)

Is it possible to tell one column to look at and query against another column?
 
K

KARL DEWEY

It is very easy if you are talking about the same record --
SELECT [Column A], [Column B]
FROM YourTable
WHERE [Column A] > [Column B];
 
J

John W. Vinson

On Thu, 4 Mar 2010 15:19:01 -0800, Freeman girl <Freeman
I have a query that has multiple columns with dates. I need to be able to
query one column against another column. Is that possile?

Example: Column A has an admission date to a hospitalization
Column B has an authorization date.

I need for my query to only pull hospitalizations (column A) that occurred
after authorizations were issued (column B)

Is it possible to tell one column to look at and query against another column?

Yes; you can use a criterion on column A such as
[Column B]

The brackets are essential and should contain the actual fieldname of the
other field. Note that relational database tables are NOT spreadsheets; the
proper jargon term is "field", not "column".

You might want to open your query in SQL view and post the SQL text here so
people can see more clearly what you're dealing with.

Also note that your subject line refers to "between two tables" and your text
"between two columns"; both are doable but the technique will be different.
 
P

PieterLinden via AccessMonster.com

SELECT [AdmissionDate], [AuthorizationDate]
FROM MyTable
WHERE [AdmissionDate]>[HospitalizationDate];
 
F

Freeman girl

Thank you for your help, this did the trick!

KARL DEWEY said:
It is very easy if you are talking about the same record --
SELECT [Column A], [Column B]
FROM YourTable
WHERE [Column A] > [Column B];

--
Build a little, test a little.


Freeman girl said:
I have a query that has multiple columns with dates. I need to be able to
query one column against another column. Is that possile?

Example: Column A has an admission date to a hospitalization
Column B has an authorization date.

I need for my query to only pull hospitalizations (column A) that occurred
after authorizations were issued (column B)

Is it possible to tell one column to look at and query against another column?
 
F

Freeman girl

Thank you for the clarifications. This helped tremendously!
John W. Vinson said:
On Thu, 4 Mar 2010 15:19:01 -0800, Freeman girl <Freeman
I have a query that has multiple columns with dates. I need to be able to
query one column against another column. Is that possile?

Example: Column A has an admission date to a hospitalization
Column B has an authorization date.

I need for my query to only pull hospitalizations (column A) that occurred
after authorizations were issued (column B)

Is it possible to tell one column to look at and query against another column?

Yes; you can use a criterion on column A such as
[Column B]

The brackets are essential and should contain the actual fieldname of the
other field. Note that relational database tables are NOT spreadsheets; the
proper jargon term is "field", not "column".

You might want to open your query in SQL view and post the SQL text here so
people can see more clearly what you're dealing with.

Also note that your subject line refers to "between two tables" and your text
"between two columns"; both are doable but the technique will be different.
 

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