A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

efficient method of finding closest date by specify input value



 
 
Thread Tools Display Modes
  #1  
Old March 8th, 2010, 06:28 AM posted to microsoft.public.access.queries
xmi
external usenet poster
 
Posts: 1
Default efficient method of finding closest date by specify input value

can it be specify the input value to the formate with YY-YY, that means let
the use to key in 09-10 from the query. and the 09-10 means the date range
(01/04/2009 to 31/03/2010)

staff
peter 01/08/2009
SAM 02/03/2009
IAN 03/01/2010
================== key in: 09-10 then, the output will shown below:
output:
peter 01/08/2009
IAN 03/01/2010

  #2  
Old March 8th, 2010, 08:25 AM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default efficient method of finding closest date by specify input value

In query design view, enter something like this (as one line) into the
Criteria row under your date field:

= DateSerial([From 1 April what year?],4,1) And

DateSerial([From 1 April what year?]+1,4,1)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"xmi" wrote in message
...
can it be specify the input value to the formate with YY-YY, that means
let
the use to key in 09-10 from the query. and the 09-10 means the date range
(01/04/2009 to 31/03/2010)

staff
peter 01/08/2009
SAM 02/03/2009
IAN 03/01/2010
================== key in: 09-10 then, the output will shown below:
output:
peter 01/08/2009
IAN 03/01/2010

  #3  
Old March 8th, 2010, 05:19 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default efficient method of finding closest date by specify input valu

Allen,
Your criteria will include SAM 02/03/2009 but it appears they want the
outer most dates.
What I do not get is their input criteria of 09-10 means the date
range (01/04/2009 to 31/03/2010).



--
Build a little, test a little.


"Allen Browne" wrote:

In query design view, enter something like this (as one line) into the
Criteria row under your date field:

= DateSerial([From 1 April what year?],4,1) And

DateSerial([From 1 April what year?]+1,4,1)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"xmi" wrote in message
...
can it be specify the input value to the formate with YY-YY, that means
let
the use to key in 09-10 from the query. and the 09-10 means the date range
(01/04/2009 to 31/03/2010)

staff
peter 01/08/2009
SAM 02/03/2009
IAN 03/01/2010
================== key in: 09-10 then, the output will shown below:
output:
peter 01/08/2009
IAN 03/01/2010

.

  #4  
Old March 8th, 2010, 06:35 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default efficient method of finding closest date by specify input valu

This will give the outer most dates --
SELECT Aaron.SalesDate
FROM Aaron
WHERE Aaron.SalesDate =(SELECT TOP 1 [XX].[SalesDate] FROM Aaron AS [XX]
WHERE [XX].[SalesDate] cvdate([bottom date]) ORDER BY [XX].[SalesDate]) OR
Aaron.SalesDate =(SELECT TOP 1 [XX].[SalesDate] FROM Aaron AS [XX] WHERE
[XX].[SalesDate] cvdate([Top date]) ORDER BY [XX].[SalesDate] DESC);

--
Build a little, test a little.


"KARL DEWEY" wrote:

Allen,
Your criteria will include SAM 02/03/2009 but it appears they want the
outer most dates.
What I do not get is their input criteria of 09-10 means the date
range (01/04/2009 to 31/03/2010).



--
Build a little, test a little.


"Allen Browne" wrote:

In query design view, enter something like this (as one line) into the
Criteria row under your date field:

= DateSerial([From 1 April what year?],4,1) And

DateSerial([From 1 April what year?]+1,4,1)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"xmi" wrote in message
...
can it be specify the input value to the formate with YY-YY, that means
let
the use to key in 09-10 from the query. and the 09-10 means the date range
(01/04/2009 to 31/03/2010)

staff
peter 01/08/2009
SAM 02/03/2009
IAN 03/01/2010
================== key in: 09-10 then, the output will shown below:
output:
peter 01/08/2009
IAN 03/01/2010

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.