473,471 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with calculated results

I am using this calculation in a query to find invoices that are less then
30 days, over 30, over 60, over 90, and over 120.

IIf((Now()-AR6_OpenInvoice1.INV_DATE)\30>4,4,(Now()-AR6_OpenInvoice1.INV_DAT
E)\30);
The problem is the invoice was created on let say 9/17/03 and is less then
30 days old but the calculation looks at it and says it is over 30. What do
I need to fix this problem?

Thanks agin for all the help!!

Greg
Nov 12 '05 #1
1 1541
It's quite possible, using Now() that, depending upon the Inv_Date and the
exact time of day the query was run, you may miss what you think should be
there. In other words, if you run the query at 8 AM, you may return more (or
fewer) records than if you run the query at 11 PM.

Now() carries a time of day value as well as the date.
Unless you are looking for records exactly 30 days to the second of when the
query is run, use Date() instead.

Also, unless the query has more than one table with the same Field Name
(Inv_Date), you don't need the table name qualifier.
If the logic of your expression is correct, try:

IIf((Date() - [INV_DATE])\30>4,4,(Date() - [INV_DATE])\30)

Or... why not make a new Module:

Function InvoiceAge(DateIn as Date)
Dim intElapsedDays as integer
Dim intResult as integer
intElapsedDays = DateDiff("d",DateIn,Date())

Select Case intElapsedDays
Case 1 to 29
intResult = 1
Case 30 to 59
intResult = 30
Case 60 to 89
intResult = 60
Case 90 to 119
untResult = 90
Case Else
intResult = 120
End Select
InvoiceAge = intResult
End Function
===============
Change the time periods and the expected results to suit yourself.
Call the function from a query:
Aged: InvoiceAge([Inv_Date])
Sort by this field.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"Greg" <gk******@itlan.net> wrote in message
news:Af******************@nwrdny01.gnilink.net...
I am using this calculation in a query to find invoices that are less then
30 days, over 30, over 60, over 90, and over 120.

IIf((Now()-AR6_OpenInvoice1.INV_DATE)\30>4,4,(Now()-AR6_OpenInvoice1.INV_DAT E)\30);
The problem is the invoice was created on let say 9/17/03 and is less then
30 days old but the calculation looks at it and says it is over 30. What do I need to fix this problem?

Thanks agin for all the help!!

Greg

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Junmou Zhang | last post by:
I have installed the PDL module and use it to calculate eigenvalue of a matrix. The PDL do gives me some eigenvalue and eigenvector. But the problem is that these values are different from the...
4
by: Ola Tuvesson | last post by:
I'm having a really weird problem. When running the SP below in query analyzer the calculated column "Subscribed" is returned as expected: ------------- CREATE PROCEDURE get_mailinglists( ...
7
by: Foxster | last post by:
in access i have two tables (tblplayer, tblpoints) in tblplayer i have field totalpoint (number) in tlbpoints i have field pointgame (number) the two files are related via idplayer now i made a...
4
by: Bill Dika | last post by:
Hi I am trying to calculate a running total of a calculated textbox (tbAtStandard) in GroupFooter1 for placement in a textbox (tbTotalAtStandard) on my report in Groupfooter0. The problem...
5
by: John Bahran | last post by:
I am trying to use calculated fields in my query but all the results are zero ven when they're not. Please help. Thanks.
5
by: Vibhesh | last post by:
I am facing problem with TimeSpan structure when DirectX is used. Following is the sample code that causes the problem: ...
4
by: dragony2000 | last post by:
I want to solve these questions using C# , Please !!! ************************************************************* 1- The factorial method is used frequently in probability problems. The...
87
by: pereges | last post by:
I have a C program which I created on Windows machine. I have compiled and executed the program on windows machine and it gives me the consistent output every time i run it. for eg. input a = 2,...
19
mshmyob
by: mshmyob | last post by:
Going to post this real fast since I have to go out, so I hope I get all the pertenent info in the message. I have a subform and the results are based on a select query. Results are say like so...
2
by: mkbrady | last post by:
I have a query that includes calculated fields that generate numeric results. I have wrapped conversion functions CLng() and CDdl() around the calculated fields to ensure the data types are...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
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,...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.