473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Showing last 3 dates

25
Hi,

I'm working on a query using MS Access 2003. Right now on my query it showed all receipt dates for items from the beginning up to now. On the report, I just want to show the last 3 receipt dates. How can I do this? Could someone help? I know for the last date I can just use max, but what about the last 2?

Thank you in advance.
Oct 21 '09 #1
4 1725
NeoPa
32,556 Expert Mod 16PB
What you need to do is sort the results in your query (by date descending) then set (Properties of the QueryDef) Top Values to 3.
Oct 21 '09 #2
Bay0519
25
Thank you Neopa for your quick response.

But now the result only showed my top 3 value on the query. But my query have all items that we receipt from beginning FY up to now. I need for all that items to show on the report, but for the date, I just need the last 3 receipts date for each items. If there's an item only have 2 dates, then the 3rd date will be blank. Can you help me please? I'm sorry for not givinng you a clear picture earlier.
here is my query
Expand|Select|Wrap|Line Numbers
  1. SELECT FY09_LastReceiptDate_1.ID, FY09_LastReceiptDate_1.TRANSACTION_DATE AS LastReceiptDate
  2. FROM FY09_LastReceiptDate_1
  3. GROUP BY FY09_LastReceiptDate_1.ID, FY09_LastReceiptDate_1.TRANSACTION_DATE
  4. ORDER BY FY09_LastReceiptDate_1.ID, FY09_LastReceiptDate_1.TRANSACTION_DATE DESC;
  5.  
Thank you.
Oct 22 '09 #3
Bay0519
25
Nevermind I found the answer. Basically I just need to create a function that showed 1, 2, 3 as a new field. then from that I just create another query that showed data with number < 4

Thank you for all your help.
Oct 22 '09 #4
NeoPa
32,556 Expert Mod 16PB
I think this can be done in pure SQL Bay (so in a QueryDef). Unfortunately I'm still not clear exactly what you're after here, so I knocked up something I hope will illustrate the concept :
Expand|Select|Wrap|Line Numbers
  1. SELECT   tTBG.GroupField,
  2.          tTBG.SortField
  3.  
  4. FROM     tblTopByGroup AS tTBG 
  5.  
  6. WHERE    tTBG.ID In(
  7.     SELECT TOP 3 inTBG.ID
  8.  
  9.     FROM         tblTopByGroup AS inTBG
  10.  
  11.     WHERE        (inTBG.GroupField=tTBG.GroupField)
  12.  
  13.     ORDER BY     inTBG.SortField
  14.     )
  15.  
  16. ORDER BY tTBG.GroupField,
  17.          tTBG.SortField
Oct 22 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Shawn McKenzie | last post by:
Can someone help me with a query to get the date/time that a database was last modified? I looked at the SHOW command but there was no mention of this. TIA, Shawn
1
by: Amanda | last post by:
Hi, hope you can help me with this one. If I want to get the date a page has been last modified, I can do something like .. document.write("<b>Last updated: "+document.lastModified+"</b>"); ...
13
by: SimonC | last post by:
I would like to return data from the last 2 weeks of each given month in Javascript, but in 2 formats. So, the penultimate week (Monday to Sunday) and the last week (Monday to ??) I'm not...
2
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups...
9
by: Robin Tucker | last post by:
Hiya, I need to test "relative dates" in my program, such as "last six months" or "last 3 months" or "in the last week" etc. How can I do this with a DateTime structure? ie. If NodeDate...
2
by: rf | last post by:
Hey I need to be able to get the dates from last wednesday to the past tuesday on thursday or friday every week. How would I do that? For example: m t W TH F M T w th f I would need the...
2
by: eloi-ribeiro.blogspot.com | last post by:
Hi, I'm having a problem with a query. I'm running Access 2000 and a table with 35000 rows. The table contains several visits to the spots with a CODE (spot code) and DATE (visit date)...
3
by: Gretsch | last post by:
Web, html, javascript, Hi, I need to calculate the time since this .htm file was last modified. {which I can then use in a calculation, rather than display, so days&decimals format would be OK}...
2
by: markcarroll | last post by:
I have a rather complicating query (the SQL is about a page long) so I hope I can solve this without needing to get into specifics. Basically, the database I am working on has information about...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.