Query with option of 2 fields (1 Viewer)

Valentine

Member
Local time
Today, 13:05
Joined
Oct 1, 2021
Messages
261
Is it possible to query off of 2 different values? I have a table that has 2 date fields, 1 for when they leave the army and 1 for when they leave the duty station. Is it possible to pull a query that gives me everyone that is 180 days from either of those 2 dates?
 

Ranman256

Well-known member
Local time
Today, 13:05
Joined
Apr 9, 2015
Messages
4,339
select DateDiff("d",[DepartArmyDate],Date()) as DepartDays, DateDiff("d",[LeaveDutyStationDate],Date()) as LeavStationDays from table

then you can filter
 

Valentine

Member
Local time
Today, 13:05
Joined
Oct 1, 2021
Messages
261
I am going to make a macro button that my users will push and just a query will open that shows all without them having to filter.

Code:
SELECT Roster.[Last Name], Roster.[First Name], Roster.Platoon, Roster.Outbound, Roster.ETS
FROM Roster
WHERE (((Roster.Outbound)<=DateAdd("d",180,Date())) AND ((Roster.ETS)<=DateAdd("d",180,Date())));

that is what I am working with currently, but i dont think its working.
 

Minty

AWF VIP
Local time
Today, 17:05
Joined
Jul 26, 2013
Messages
10,354
This should be an OR in the middle, I think?

WHERE (((Roster.Outbound)<=DateAdd("d",180,Date())) AND ((Roster.ETS)<=DateAdd("d",180,Date())));
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:05
Joined
Feb 19, 2002
Messages
42,971
The date for duty should be in a separate table since starting/ending duty stations happens multiple times whereas starting/ending service generally happen only once each.
 

Users who are viewing this thread

Top Bottom