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  

Criteria using DateDiff function in SELECT Query.



 
 
Thread Tools Display Modes
  #1  
Old September 23rd, 2004, 02:31 PM
EricB
external usenet poster
 
Posts: n/a
Default Criteria using DateDiff function in SELECT Query.

I have a query that used te DateDiff function.
The purpose of the query is to show the records that are
older then 30 days up until 120 days.

I'm using this in the query:
dayselapsed: DateDiff("d",[POdate],Now())
and for the criteria for the field dayselapsed
I have 30 and =120.

Is there a way so that my users can specify these numbers
by themselves? So that each time you run the query the
system aks you enter the period and whereby you then
enter the nrs. So for example if you want to see the
records that are older then 1 day up until 60 days you
would enter 1 and 60. Is this technically possible using
a SELECT QUERY??? THANKS FOR ANY SUGGESTIONS...


  #2  
Old September 23rd, 2004, 03:07 PM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default

Check Access HELP on "parameter query".

Basically, you'll be replacing your criterion statement with something like:

[Enter 'low' days] And = [Enter 'high' days]


Note that this does NOT give you a mechanism for validating that:
1. a number was entered (unless you also set the parameter type in the
query)
2. a number was entered in both
3, the first number is smaller than the second

To do these things, I'd suggest creating a form you use to gather these, use
the events for the form and the controls to ensure these validation rules
are followed, and then refer to the form's controls in your criterion
statement, something like:

Forms!YourFormName!YourLowestDaysControlName And =

Forms!YourFormName!YourHighestDaysControlName

(beware of wordwrap in email)

--
Good luck

Jeff Boyce
Access MVP

  #3  
Old September 24th, 2004, 08:36 AM
EricB
external usenet poster
 
Posts: n/a
Default

This does not work, I have already tried this before.
It is probably due to the fact that I'm using the
DateDiff function in the query.

Thanks anyway....

-----Original Message-----
Check Access HELP on "parameter query".

Basically, you'll be replacing your criterion statement

with something like:

[Enter 'low' days] And = [Enter 'high' days]


Note that this does NOT give you a mechanism for

validating that:
1. a number was entered (unless you also set the

parameter type in the
query)
2. a number was entered in both
3, the first number is smaller than the second

To do these things, I'd suggest creating a form you use

to gather these, use
the events for the form and the controls to ensure these

validation rules
are followed, and then refer to the form's controls in

your criterion
statement, something like:

Forms!YourFormName!YourLowestDaysControlName And =

Forms!YourFormName!YourHighestDaysControlName

(beware of wordwrap in email)

--
Good luck

Jeff Boyce
Access MVP

.

 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
bug in access calling function from insert into query??? Michael Running & Setting Up Queries 3 August 26th, 2004 04:51 PM
UNION Query with Criteria Dkline Running & Setting Up Queries 1 August 4th, 2004 09:15 PM
Struggling with MS Query... Alex General Discussion 5 July 6th, 2004 11:46 AM
Delete Query based on result of select query John Finch Running & Setting Up Queries 1 July 2nd, 2004 05:47 PM


All times are GMT +1. The time now is 09:31 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.