Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Need to find years that are the same in a query in Access.?

I need to find years that are equal in a query but for several different years. Here is what the Access query needs to do:

I have the fields x, y, z, and date.

I need x and y to be equal and z to be different. Also, if that is true then I need them to be in the same year. How can I write something that is looking for the year to be the same but different years at the same time?

Update:

that was somewhat confusing so i will try and elaborate. example: with fields x, y, z and date comparing two different entries.

x and y are equal so x = 1 for both and y = yes for both

z is not equal so one entry z = 5 and one z=6

if that is true i there should be two different dates for the same year and i am trying to compare the difference in days so one is 4/5/2007 and one is 4/6/2007. I need to record all of the records like this.

I know it is still confusing but i hope this helps

Update 2:

yes i was talking about same year but different month/days. : )

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    I don't quite understand your question. Did you perhaps mean 'dates (as in month and day) that are the same but in different years'?

    (Edit)

    OK, I think I follow you now - you want rows from the same table (call it 'tab' with fields x, y, z and date) with a result set as you describe. This might get you somewhere in the ballpark (syntax for date function probably a bit off - don't have ref book handy)

    select a.z, b.z, a.date, b.date from tab a, tab b

    where a.x = b.x and a.y = b.y and a.z <> b.z and a.date <> b.date and year(a.date) = year(b.date)

Still have questions? Get your answers by asking now.