SQL Query Statement Help

foxhound

Board Regular
Joined
Mar 21, 2003
Messages
182
Hello,

This is the code that I need but, I need help on the between dates portion. How should the "dateadd(“yyyy”,-1,[MaxDate])+1" portion be written?

SELECT [Payroll Transaction History].EmpNo, [Payroll Transaction History].Date, [Payroll Transaction History].DBA, [Payroll Transaction History].Hours, [Payroll Transaction History].YTDIncNo, [Pay Types].Vac, [Pay Types].[DBA Description]
FROM [Payroll Transaction History] INNER JOIN [Pay Types] ON [Payroll Transaction History].DBA = [Pay Types].DBA
WHERE ((([Payroll Transaction History].Date) Between dateadd(“yyyy”,-1,[MaxDate])+1 And [MaxDate]) AND (([Pay Types].Vac)="y"));

As always, any suggestions would be greatly appreciated.

-Foxhound
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Okay, I figured this one out. I added a text box to my report named [txt_roll12MaxDate] and set it equal to dateadd("yyyy",-1,[maxdate])-1 and then substituted "between [txt_roll12maxdate] and [maxdate]" in the code for Between dateadd(“yyyy”,-1,[MaxDate])+1 And [MaxDate].

Thanks.
 
Upvote 0

Forum statistics

Threads
1,221,687
Messages
6,161,287
Members
451,695
Latest member
Doug Mize 1024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top