Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stuck with this Query

Status
Not open for further replies.

MrMcFestoe

Technical User
Apr 6, 2003
119
GB
I have a query that i cant get to work, so iam about to give up, any help or ideas on this would be great.

I have a field called LAST_SERVICE_VISIT which displays the date a service was made on a system ddmmyyyy this works fine and pulls the information from a subform.

I also have a field SERVICE_FREQ which is a combo box and can equal 3, 6, 12 months.

what iam trying to do is have a query list the systems that have not been serviced within the SERVICE_FREQ of the date the query is run.

so if SERVICE_FREQ = 12 then list all systems that have not been serviced in the last 12months of the current date.

does that make sense.

Thanks
 
[tt]select somecolumns
from thetable
where (
SERVICE_FREQ = 3
and LAST_SERVICE_VISIT < dateadd(&quot;m&quot;,-3,Date())
)
or (
SERVICE_FREQ = 6
and LAST_SERVICE_VISIT < dateadd(&quot;m&quot;,-6,Date())
)
or (
SERVICE_FREQ = 12
and LAST_SERVICE_VISIT < dateadd(&quot;m&quot;,-12,Date())
)[/tt]

rudy
 
rudy

thanks for the quick reply, where does it go. Does it go in the query (desgin view)??

Thanks
 
yes... Query, Design, SQL View

paste into the window and run it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top