[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MS Access Ship Date

Posted on 2006-05-17
5
Medium Priority
?
212 Views
Last Modified: 2008-02-20
Hi Guys,

thanks in advance. I have a query in which I'm trying to get the latest ship date but going back 11 month. Is there any function that would allow me to get this info.

so far I've applied the mix function but I need to go back 11 month.
Thanks!

Joe

0
Comment
Question by:JoeSand2005
  • 3
  • 2
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 16702922
dateadd("m",-11,somedate)

from somedate, it returns the date 11 months ago
0
 

Author Comment

by:JoeSand2005
ID: 16709482
Hey Rockiroads,

Thanks for your help. I still don't get what I'm looking for.
Note: I apply your function but doesn't work. Do you guys know why?
Here is the query I created:


SELECT Max([Orders].[Ship Date]) AS [Last Ship Date], Contacts.FirstName, Contacts.LastName, Contacts.Emails
FROM Contacts LEFT JOIN [GC-Orders] ON Contacts.ContactID = [Orders].CompanyID
GROUP BY Contacts.FirstName, Contacts.LastName, Contacts.Emails, Contacts.CompanyName
HAVING (((Max([Orders].[Ship Date]))>= dateadd("m", -11, [Ship Date]))
ORDER BY Max([Orders].[Ship Date]) DESC;
0
 

Author Comment

by:JoeSand2005
ID: 16709498
Just One Clarification companyname is not part of the query
thanks!

SELECT Max([Orders].[Ship Date]) AS [Last Ship Date], Contacts.FirstName, Contacts.LastName, Contacts.Emails
FROM Contacts LEFT JOIN [Orders] ON Contacts.ContactID = [Orders].CompanyID
GROUP BY Contacts.FirstName, Contacts.LastName, Contacts.Emails
HAVING (((Max([Orders].[Ship Date]))>= dateadd("m", -11, [Ship Date]))
ORDER BY Max([Orders].[Ship Date]) DESC;
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 375 total points
ID: 16712340
your query, dont u need to use the current date in DateAdd? is that not going back 11 months?


another way

put it as a WHERE instead, and wrap with format

lets try this


SELECT Max([Orders].[Ship Date]) AS [Last Ship Date], Contacts.FirstName, Contacts.LastName, Contacts.Emails
FROM Contacts LEFT JOIN [Orders] ON Contacts.ContactID = [Orders].CompanyID
WHERE Format([Orders].[Ship Date],'YYYYMM' <= Format(DateAdd("m",-11,Now()),'YYYYMM')
GROUP BY Contacts.FirstName, Contacts.LastName, Contacts.Emails
ORDER BY Max([Orders].[Ship Date]) DESC;
0
 

Author Comment

by:JoeSand2005
ID: 16755498
Thanks Rockiroads it works, eventhough I was having some problems becouse of the fact that I wanted the most recent ship date.

Thanks!

0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question