See Data in Query with Dates that are not equal

net

Registered User.
Local time
Today, 07:40
Joined
Mar 12, 2006
Messages
50
Hello,

How can I get my query to output years that does not equal the same year?

For example:

I have a Begin Year and an End Year. I need to see if the begin year is not equal to the end year (10/10/2016 = 10/10/2017 )

I would like to add the expression to my query design criteria Begin Date field.

I am using Microsoft Access 2013.

Thank you.
 
You can calculate the year of a date field in your query using the Year() function, so you can do...
SELECT Year(YourDateField) as YourYear
FROM table...
To constrain data in a query you would use this same concept, but in the WHERE clause, like...
SELECT t.*
FROM YourTable As t
WHERE Year(t.YourDateField) >= [prmStartYear] AND Year(t.YourDateField) <= [prmEndYear]
Does that make sense? Is that what you are asking?
 
Thank you Mark for your response. I am not sure if I want or need to calculate the years.

I have two columns, one called "Begin Year" and another column called "End Year". I need to see where the begin/end year is not the same.

Example below shows the first row as different years (2016/2017).

Begin Year End Year

10/1/2016 2/1/2017
11/1/2016 11/30/2016
 

Users who are viewing this thread

Back
Top Bottom