How to get a Qry total for the past 6 Mo

T

Thanks, Chad

Hello, I have a query that shows me every time that the word "Vacation" was
used in tblInput. I have a form hidden that its getting its info from named
frmCalendar. In the Sql below it is taking the infor for the entire year that
is selected on frmCalendar. I need it to also take it from a control named
month but only sow the word "Vacation" starting Now to back 6 months. How
would the statement go?
 
T

Thanks, Chad

Sorry forgot the SQL....


SELECT Year([inputdate]) AS [Year], tblInput.InputDate, tblInput.InputText,
tblInput.UserID
FROM tblInput
WHERE (((Year([inputdate]))=[Forms]![frmCalendar].[year]) AND
((tblInput.InputText)="Vacation") AND
((tblInput.UserID)=[forms]![frmCalendar]![cboUser]))
ORDER BY tblInput.InputDate;
 
J

John W. Vinson/MVP

You need to use the Date() function and not the Now() function. Put the
following expression in the VacationDate field of your query:
Between Month(Date()) and DateAdd("mm",-6,Date())

Steve, check your logic there. Month(Date()) will return an integer 7
(today anyway), which when interpreted as a date will be January 5,
1900. Probably not what the user wants! Also, mm is not a recognized
argument for DateAdd (it is for Format).

BETWEEN DateAdd("m", -6, Date()) AND Date()

will return all records within the past six months.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top