Query Formula Help

I have a field "Last Contact Date" in a query.  I need to create a formula to 
show me the records that have a last contact date more than 30 days old.  Any 
thoughts???

Thanks.
0
Utf
1/24/2008 3:13:01 PM
access.formscoding 7493 articles. 0 followers. Follow

12 Replies
731 Views

Similar Articles

[PageSpeed] 34

WHERE DateDiff("d", [YourTable].[Last Contact Date], Now()) > 30

HTH;

Amy

"Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
news:820174F0-445C-472D-8B1C-F6711482D8C0@microsoft.com...
>I have a field "Last Contact Date" in a query.  I need to create a formula 
>to
> show me the records that have a last contact date more than 30 days old. 
> Any
> thoughts???
>
> Thanks. 


0
Amy
1/24/2008 3:21:31 PM
This is what i entered and I get an error

Expr1: Where DateDiff("d",[CRS Current Clients_qry].[Last Contact 
Date],Now())>30

Is that correct?

Thanks 

"Amy Blankenship" wrote:

> WHERE DateDiff("d", [YourTable].[Last Contact Date], Now()) > 30
> 
> HTH;
> 
> Amy
> 
> "Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
> news:820174F0-445C-472D-8B1C-F6711482D8C0@microsoft.com...
> >I have a field "Last Contact Date" in a query.  I need to create a formula 
> >to
> > show me the records that have a last contact date more than 30 days old. 
> > Any
> > thoughts???
> >
> > Thanks. 
> 
> 
> 
0
Utf
1/24/2008 3:39:06 PM
WHERE [Last Contact Date] <= DateAdd("d", -30, Date)

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
news:820174F0-445C-472D-8B1C-F6711482D8C0@microsoft.com...
>I have a field "Last Contact Date" in a query.  I need to create a formula 
>to
> show me the records that have a last contact date more than 30 days old. 
> Any
> thoughts???
>
> Thanks. 


0
Douglas
1/24/2008 3:44:38 PM
"Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
news:9D213BB1-1B3A-4F62-9A39-FC3068872678@microsoft.com...
> This is what i entered and I get an error
>
> Expr1: Where DateDiff("d",[CRS Current Clients_qry].[Last Contact
> Date],Now())>30
>
> Is that correct?

No.

In the top row of the query grid, enter

TimeSinceContact: DateDiff("d",[CRS Current Clients_qry].[Last Contact
> Date],Now())

In the row just beneath the check box, enter

> 30

HTH;

Amy 


0
Amy
1/24/2008 3:51:39 PM
I entered: Expr1: [Last Contact Date]<=DateAdd("d",-30,[Date]) and it prompts 
me for a parameter value. 

"Douglas J. Steele" wrote:

> WHERE [Last Contact Date] <= DateAdd("d", -30, Date)
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> 
> "Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
> news:820174F0-445C-472D-8B1C-F6711482D8C0@microsoft.com...
> >I have a field "Last Contact Date" in a query.  I need to create a formula 
> >to
> > show me the records that have a last contact date more than 30 days old. 
> > Any
> > thoughts???
> >
> > Thanks. 
> 
> 
> 
0
Utf
1/24/2008 3:52:02 PM
That worked!!!  Thank you very much.

"Amy Blankenship" wrote:

> 
> "Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
> news:9D213BB1-1B3A-4F62-9A39-FC3068872678@microsoft.com...
> > This is what i entered and I get an error
> >
> > Expr1: Where DateDiff("d",[CRS Current Clients_qry].[Last Contact
> > Date],Now())>30
> >
> > Is that correct?
> 
> No.
> 
> In the top row of the query grid, enter
> 
> TimeSinceContact: DateDiff("d",[CRS Current Clients_qry].[Last Contact
> > Date],Now())
> 
> In the row just beneath the check box, enter
> 
> > 30
> 
> HTH;
> 
> Amy 
> 
> 
> 
0
Utf
1/24/2008 4:01:01 PM
Remove the square brackets around Date: it's supposed to be a reference to 
the Date function. If Access inserts them for you, put Date() instead.

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
news:C2F2347F-4C5A-4220-8408-5721313CF624@microsoft.com...
>I entered: Expr1: [Last Contact Date]<=DateAdd("d",-30,[Date]) and it 
>prompts
> me for a parameter value.
>
> "Douglas J. Steele" wrote:
>
>> WHERE [Last Contact Date] <= DateAdd("d", -30, Date)
>>
>> -- 
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "Jimmy" <Jimmy@discussions.microsoft.com> wrote in message
>> news:820174F0-445C-472D-8B1C-F6711482D8C0@microsoft.com...
>> >I have a field "Last Contact Date" in a query.  I need to create a 
>> >formula
>> >to
>> > show me the records that have a last contact date more than 30 days 
>> > old.
>> > Any
>> > thoughts???
>> >
>> > Thanks.
>>
>>
>> 


0
Douglas
1/24/2008 4:15:03 PM
A problem with that approach is that the function has to get called for 
every row in the table. (Another problem is that it'll have problems if Last 
Contact Date is Null for any row)

Putting DateAdd("d", -30, Date()) as the criteria means the function only 
gets called once.

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Amy Blankenship" <Amy_nospam@magnoliamultimedia.com> wrote in message 
news:u4mge4pXIHA.4696@TK2MSFTNGP05.phx.gbl...
> WHERE DateDiff("d", [YourTable].[Last Contact Date], Now()) > 30
>
> HTH;
>
> Amy
>
> "Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
> news:820174F0-445C-472D-8B1C-F6711482D8C0@microsoft.com...
>>I have a field "Last Contact Date" in a query.  I need to create a formula 
>>to
>> show me the records that have a last contact date more than 30 days old. 
>> Any
>> thoughts???
>>
>> Thanks.
>
> 


0
Douglas
1/24/2008 4:17:31 PM
I made that a required field.  I'm assuming that should alleviate the issue???

"Douglas J. Steele" wrote:

> A problem with that approach is that the function has to get called for 
> every row in the table. (Another problem is that it'll have problems if Last 
> Contact Date is Null for any row)
> 
> Putting DateAdd("d", -30, Date()) as the criteria means the function only 
> gets called once.
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> 
> "Amy Blankenship" <Amy_nospam@magnoliamultimedia.com> wrote in message 
> news:u4mge4pXIHA.4696@TK2MSFTNGP05.phx.gbl...
> > WHERE DateDiff("d", [YourTable].[Last Contact Date], Now()) > 30
> >
> > HTH;
> >
> > Amy
> >
> > "Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
> > news:820174F0-445C-472D-8B1C-F6711482D8C0@microsoft.com...
> >>I have a field "Last Contact Date" in a query.  I need to create a formula 
> >>to
> >> show me the records that have a last contact date more than 30 days old. 
> >> Any
> >> thoughts???
> >>
> >> Thanks.
> >
> > 
> 
> 
> 
0
Utf
1/24/2008 4:43:05 PM
Well, it should eliminate the possibility of Null dates causing a problem, 
but it's still far less efficient to make the multiple function calls rather 
than a single one.

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
news:25B8D8C3-F96D-46D3-A8CF-275510B88E34@microsoft.com...
>I made that a required field.  I'm assuming that should alleviate the 
>issue???
>
> "Douglas J. Steele" wrote:
>
>> A problem with that approach is that the function has to get called for
>> every row in the table. (Another problem is that it'll have problems if 
>> Last
>> Contact Date is Null for any row)
>>
>> Putting DateAdd("d", -30, Date()) as the criteria means the function only
>> gets called once.
>>
>> -- 
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "Amy Blankenship" <Amy_nospam@magnoliamultimedia.com> wrote in message
>> news:u4mge4pXIHA.4696@TK2MSFTNGP05.phx.gbl...
>> > WHERE DateDiff("d", [YourTable].[Last Contact Date], Now()) > 30
>> >
>> > HTH;
>> >
>> > Amy
>> >
>> > "Jimmy" <Jimmy@discussions.microsoft.com> wrote in message
>> > news:820174F0-445C-472D-8B1C-F6711482D8C0@microsoft.com...
>> >>I have a field "Last Contact Date" in a query.  I need to create a 
>> >>formula
>> >>to
>> >> show me the records that have a last contact date more than 30 days 
>> >> old.
>> >> Any
>> >> thoughts???
>> >>
>> >> Thanks.
>> >
>> >
>>
>>
>> 


0
Douglas
1/24/2008 7:44:03 PM
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message 
news:eyMDhSqXIHA.4140@TK2MSFTNGP04.phx.gbl...
>A problem with that approach is that the function has to get called for 
>every row in the table. (Another problem is that it'll have problems if 
>Last Contact Date is Null for any row)
>
> Putting DateAdd("d", -30, Date()) as the criteria means the function only 
> gets called once.

Good point.  I never claimed to be good with dates, which is why I planted 
figs ;-). 


0
Amy
1/24/2008 8:51:20 PM
"Jimmy" <Jimmy@discussions.microsoft.com> wrote in message 
news:C2F2347F-4C5A-4220-8408-5721313CF624@microsoft.com...
>I entered: Expr1: [Last Contact Date]<=DateAdd("d",-30,[Date]) and it 
>prompts

Enter the [Last Contact Date] on the Expr1 line, and <= DateAdd(...) on the 
line just below the check box.  That's what that line is for.  It is called 
the criteria line, and what it means is "compare what you got in the first 
line to whatever is in this line."

HTH;

Amy 


0
Amy
1/24/2008 8:53:52 PM
Reply:

Similar Artilces:

Timer for Queries?
Does anyone know of a macro or add-on that I could use as a simple timer for queries? I don't like to use the CPU time in the Task Manager because of it's inaccuracy when not receiving full CPU usage. THanks for any suggestions -- cmungs Exactly what are you trying to accomplish? Are you trying to cause a query to run automatically every so often? If so, you will need to use the timer event on a form to do that. -- Lynn Trapp Microsoft MVP (Access) www.ltcomputerdesigns.com "cmungs" <cmungs@discussions.microsoft.com> wrote in message news:88EC7019-045F-4EF...

Hyperlink help #2
I have an array formula that creates a hyperlink:- =IF(K24=0,"",HYPERLINK("[inventory.xls]Inventory!a"&MATCH($A$1&$A24& $B24,Inventory.xls!$A$2:$A$10000&Inventory.xls!$D$2:$D $10000&Inventory.xls!$E$2:$E$10000,0)+1,"[inventory.xls]Inventory! a"&MATCH($A$1&$A24&$B24,Inventory.xls!$A$2:$A$10000&Inventory.xls!$D $2:$D$10000&Inventory.xls!$E$2:$E$10000,0)+1)) this works and creates the hyperlink:- [Inventory.xls]Inventory!a1 this works fine, but when the workbook inventory.xls is closed, nothing at all works when i clickon th...

change formula
Hi, i need to be able to change the following formula: =IF(OR(R5="25/08/2008",GM5="25/08/2008",GO5="25/08/2008","Before last 7 days","Last 7 days") I want to let the user type into a cell so that the dates are all chnaged in this formula Thanks Use cells for the dates and refer to those cells in the formula. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Dal" <Dal@discussions.microsoft.com> wrote in message news:DA6EFC33-C59D-45A4-B0C5-A7F80CEEBB5D@microsoft.com... > H...

Erratic results from query criteria
I am getting different results from running the same query with the same selections. One moment it is all behaving as expected, the next it has gone haywire. (I have done what appears to me to be EXACTLY what I have done in another database, where it works perfectly every single time.) In a query I have, amongst others, the following fields: Category SubCategory Company I want to be able to select any OR ALL of the relevant fields. I have the following criteria: Like "*"&[Type Category otherwise leave blank for ALL]&"*" Like "*"&a...

Excel 2003 Function Help
I need help coming up will a function that will average a range in one column based on if the hours match. Here is my set up. -------A-------B 1.....09:21....12 2.....09:46....24 3.....09:57....17 4.....10:04....22 I need to average column B if column A's hour is the same as the hour in a cell in another worksheet. Ryan Hicks wrote: > I need help coming up will a function that will average a range in one column > based on if the hours match. Here is my set up. > > -------A-------B > 1.....09:21....12 > 2.....09:46....24 > 3.....09:57....17 &...

Update Query ?
Is there a way to 1) Assign events when adding in data thru an update query for example if you append a bunch of data into a table could you then do some kind of an update query to say if there is an initial event and no others tag this one Renewal 1 etc.. the only real data you have to go on would be Customer A and the total amt .. the event, renewal event and the delta would all need to be added in example: Say Customer A comes in with an initial deal then Customer A renews their deal So, the data would look like when you're done.: Year Custo...

design query match anywhere?
In the design query I want to match the letters "ABC" anywhere in the column 'description'. I could not get instr to work by using: InStr(description, "ABC")) > 0 How else can I match ABC (upper and lowercase) to anywhere in my 'description' column? Thanks! Are you saying you put that InStr bit as a criteria under your Description field in the query designer? Try putting Like "*ABC*" as the criteria instead. Alternatively, you could add a computed field to the query InStr([Description, "ABC") and then put >0 as the ...

Formula Dependant Conditional Formatting
I am wanting conditional formatting on an entire column of data (B). Each cell's format is dependent on the data in the cell directly to its left (A). When I select the Conditional Formatting for B1 and enter the formula to make it dependant on A1, it works fine. I then copy the formatting down the row. The only problem is that the format in all the cells are dependant on A1, not their respective cells from column A. Is there a way to copy the conditional format down a column that will cause the format's formula to change respectively like formulas in the cells themselves do? m...

Unexpected Error- Running Advance Find Query
I am getting a message that says "Unexpected Error An Error has occurred" when I am running an advanced find query on two custom entities. It seems to be when I have certain custom fields included in my view that the query errors out. Any help on this would be greatly appreciated. Thanks so much. Just wanted to add that I seem to get errors when there is a 0.00 amount in these fields... "TJ" wrote: > I am getting a message that says "Unexpected Error An Error has occurred" > when I am running an advanced find query on two custom entities. It se...

letters in IF formulas? #3
If the value in a cell is a letter, can that be used in an IF formula? I am making a simple chore worksheet for my kids. Each chore (cell) is represented by a letter. Also, each chore is worth a certain amount of money (i.e. K chore is worth $1) I would like them to be able to enter in their chore letter when it's completed and let the spread sheet enter and calculate the amounts and running totals. Can this be done? For example: =IF(c7=K,1,IF(c7=X,2)) HI No problem, type it this way =IF(A1="A",1,IF(A1="B",2,"")) adjust range to your needs. You ca...

Help question update from 2000 -2003
I am updating from office 2000 to 2003. I am not comp. savy but trying to do a safe update and some advice. I backed up all office files, contacts e-mailss etc to a PST. When I installed 2003 disk it asked me to remove 2000 first. So I asume the procedure I would do is to add/remove 2000 install 2003 and import back the PST. I thought since this was a update that it did everything Automactily Should my 2000 PST back up, restore to the 2003 office when installed ? If I remove 2000 I have no disks to reinstall if things should go south Is there away I can have both copies on ...

keep value if formula has no data
I have a worksheet that automatically updates everyday and works some calculations for me. How can I get the formula sheet to keep the value from the previous day if there is no data today. Because now it is filling in all my cells with zeros. Thanks -- Nicki Taylor Post your formula. -- Regards, RD ---------------------------------------------------------------------------- ------------------- Please keep all correspondence within the Group, so all may benefit ! ---------------------------------------------------------------------------- ------------------- "NTaylor" <...

conditional formula question
I have a spreadsheet which shows, in column A, several phsical location of a variety of insect traps. In other words, I have replicates o several trap types arranged by field location. In column B I have th corresponding number of each trap type at each location. Is there a wa to construct a formula which will return the sum of all of trap type 'x from all locations. Here is an excerpt from the worksheet: Hanley CM Study Traps Biolure 1x 1 L2 (9008) 1 Biolure 10x 1 Megalure 1 DA (8693) 2 Combo (9010) 2 DA20 (8997) 2 Da20/CM3 (9228) 2 Val...

pass through query
If a combobox is populated by a pass-through query, does it requery every time the form is closed and reopened? Thanks, Sam Yes. John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of Maryland Baltimore County Sam wrote: > If a combobox is populated by a pass-through query, does it requery every > time the form is closed and reopened? > Thanks, > Sam ...

Help
I am using Exchange 5.5 SP4 + IIS 4.0. OWA often stops response after installing the Mailbox Manager, says - error 'ASP 0115' Unexpected error /exchange/CHS/logon.asp A trappable error occurred in an external object. The script cannot continue running. When this happens, I can't stop and restart WWW publishing service with Control Panel, the only way is to reboot the whole NT system. Have stopped the mailbox manager service and reapplied SP4, but just useless. Pls help! Thanks! I've never heard of that happening. You might try reinstalling Exchange to reinstall OWA. ...

a count field in a query?
Hello, I have a query in which I would like to create a field which increments by 1 for each record selected, so if there are 10 records selected by the query, this column would show numbers 1 to 10. Ideally I would like to have some text in front of each number, say invoice1, invoice2 etc. From a previous posting I realise that this is frowned upon but it would be the simplest solution for my problem! How can I do this? Thanks Geoff On Mon, 03 Dec 2007 08:54:00 +0000, Geoff Cox <<>> wrote: >Hello, > >I have a query in which I would like to create a field which >...

Is there a Variable formula
Hello All, I am doing a Capacity analysis sheet and I am trying to create forumula that takes Open inventory (B10) Production from Supplier (C10) Consumption (D10) then 14 days of Supply (G10) 21 days of Supply (H10). Currently (B10) is a Formula (B9+C9-D9) This repeats down the colum Now Currently I am manually inputing data Cusmption (D10) & Productio (C10). What I am looking to do is write a formula that would be in tha Production (C10). This formula would come up with any number tha would make (B11 an avervage of G10 and H10) I just don't know how to write it. Is ...

Saving Username and Pass with Web Queries
I am pulling data from a website that requires you to provide a usernam and password everytime you visit the site. Excel has cachin capabilities, but everytime you close excel and try and open up th spreadsheet again, it can't login. What is the fix for this? Thanks, Hend -- Message posted from http://www.ExcelForum.com Bump! --- Message posted from http://www.ExcelForum.com/ ...

Birthday query for many children in one record
I have a database for the church, it has one main flat table only. Each record for the parents have field for child1 name, child1birthday, child2 name, child2birthday, child3 name, child3birthday - up to 5 children. I am having difficulty trying to get a report to list the birthdays of the children like this parent name, child 1 name, child 1 birthday month etc. so you get something like this:- Parent John Smith, child Mary Smith January 3 Parent Fred Jones, child Bert Jones March 4 Parent John Smith, child Jane Smith March 6 Parent Harry Brown, child Jane Brown March 6 Parent Bert Taylor,...

Unresponsive Query Wizard
Hi there, I have an Excel 2003 user who is using a spreadsheet that pulls data from our SQL server. When he opens it and refreshes the data it is fine, it pulls the current data, but when he tries to edit the query, the Query Wizard does not appear, he can see it on the task bar, but when he switches focus using task manager everything is greyed out and nothing works. I have tested the file from my computer and it is fine, which suggests a problem with his machine or installation. Does anyone have any ideas? Cheers, Steve Dooza wrote: > Hi there, > I have an Excel 2003 user who...

How I do this formula ?
I would like to format all words that said �customer� in a column to chosen color.Can anyone provide a formula or conditional formattin that will do this -- HR15 ----------------------------------------------------------------------- HR157's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3445 View this thread: http://www.excelforum.com/showthread.php?threadid=54371 You could apply an autofilter to the column and select Custom | Contains then enter customer. This will only display those rows which contain customer in that column, and you can highlight the cells...

Purchase Orders copying (URGENT HELP PLEASE)
Can the purchase orders from one database be copied to the new live database. One of my customers had a database with several purchase order and now he has created a new database but he want his purchase orders to come over tot he new database. ...

Tighter formula than this?
Hello! Is there a shorter way to write this formula? =UPPER(IF(G4="","",G4&", "&G5&" "&G6&IF(G6="","","."))&CHAR(10)&IF (H4="","",H4&", "&H5&" "&H6&IF(H6="","","."))&CHAR(10)&IF (I4="","",I4&", "&I5&" "&I6&IF(I6="","","."))&CHAR(10)&IF (J4="","",J4&", "&J5&"...

Formula for a fill color help
I can't figure out how to make a formula that will recognize a color a a value. More specifically; If b1 is made to be green (color index 4) would like c1 to insert the letter Y. I am I'm looking for an I statement so I can use it throughout the whole workbook. The formula if I understand it should kind of look like (in C1): =If(b1=colorindex4,"Y","") I'm looking to put a "Y" in c1 if b1 is colored in green. I would really like to also know how to insert a fill color in an formula! Thank you for any of your help and time, Brya -- Bryan J Yo...

Another simple query
Dear all, I have a table that contains first names and last names in different fields. Is there any way to write a query that will give as a result the first name and last name in the same field? I hope this makes sense. Thanks in advance! SELECT [last_name_field] & ", " & [first_name_field] AS whole_name FROM [your_name_table] Change the field and table names to whatever your actual fields and tables are. Cheers, Jason Lepack On Apr 23, 9:47 am, Homer <peter.a.r...@googlemail.com> wrote: > Dear all, > > I have a table that contains first names an...