Query to return records for a given year (1 Viewer)

Jkittle

Registered User.
Local time
Yesterday, 17:26
Joined
Sep 25, 2007
Messages
100
Okay I've searched the forum and have not found exactly what I'm looking for.

I'm trying to create a query to show me records for a given year. The issue I'm having is that each record has (4) dates fields and each record can contain null values.

Is it possible to do this in a query with data like the example below?

Field 1 ID (1), Field 2 Date (12/22/2012), Field 3 Date (2/06/2013), Field 3 Date (Null), Field 4 Date (Null)

In this example I would want 2013 data but would need to be able to search any year. I could also have dates in all (4) fields

Thank for your help
Jerry
 

sensetech

An old, bold coder
Local time
Today, 01:26
Joined
May 1, 2009
Messages
41
Something like

select <whatever> from <table> where year(nz(Field1,'1 Jan 1899')) = pYear or year(nz(Field2,'1 Jan 1899')) = pYear or year(nz(Field3,'1 Jan 1899')) = pYear or year(nz(Field4,'1 Jan 1899')) = pYear

where pYear is the year for which you want data and it won't be 1899!
 

namliam

The Mailman - AWF VIP
Local time
Today, 02:26
Joined
Aug 11, 2003
Messages
11,695
no need for the nz function, but all the rest is spot on
 

sensetech

An old, bold coder
Local time
Today, 01:26
Joined
May 1, 2009
Messages
41
Just checked namliam's point - he's quite right. That's what I get for answering off the top of my head rather than testing my theories ;)
 

Users who are viewing this thread

Top Bottom