MS Access Ship Date

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

JoeSand2005Asked:
Who is Participating?
 
rockiroadsCommented:
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
 
rockiroadsCommented:
dateadd("m",-11,somedate)

from somedate, it returns the date 11 months ago
0
 
JoeSand2005Author Commented:
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
 
JoeSand2005Author Commented:
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
 
JoeSand2005Author Commented:
Thanks Rockiroads it works, eventhough I was having some problems becouse of the fact that I wanted the most recent ship date.

Thanks!

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.