0

Say I have these tables with field names underneath.

DailyLeaveLedger
dldEmployeeID
dldLeaveDate

InvoiceHeader
invEmployeeID
invWeekEnding
InvNumberWeeksCovered

So I want a query selects leave days where an invoice covers that leave ie invWeekEnding 02 Oct and InvNumberWeeksCovered = 1 then any leave in the range 26 Sep to 02 Oct is ok. Also you have to have EmployeeiD fields match.

In MSAccess 2003 please?

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Malcolm
  • 12,524
  • 28
  • 89
  • 125

1 Answers1

0

Try this

SELECT InvoiceHeader.invEmployeeID, 
       InvoiceHeader.invWeekEnding, 
       DateAdd("d",-[InvNumberWeeksCovered]*7,[invWeekEnding]) AS StartDate,
       DailyLeaveLedger.dldLeaveDate
  FROM InvoiceHeader 
       INNER JOIN DailyLeaveLedger 
          ON InvoiceHeader.invEmployeeID = DailyLeaveLedger.dldEmployeeID
WHERE (((DailyLeaveLedger.dldLeaveDate) 
         Between [invWeekEnding] 
         And DateAdd("d",-[InvNumberWeeksCovered]*7,[invWeekEnding])));

What I did was add -7 * InvNumberWeeksCovered to the invdate, and then check for dates between these.

Hope that helps.

onedaywhen
  • 55,269
  • 12
  • 100
  • 138
Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284