473,405 Members | 2,349 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,405 software developers and data experts.

Average Payment in Days

I inserted this statement and it worked great for the customers that
have no payment history, but for the customers that have a history and
an open invoice, it still used today's date in the mix and came back
with screwy math. For instance, a customer who actually has an
average payment of 20 days and has an open invoice 12 days old was
calculated at an average of 102 days.... I'm fuzzy, but not that
fuzzy! How do I tell Access to only use today if there is no payment
date as of yet?
Re: Average Payment in Days
From: Brendan Reynolds
Date Posted: 2/11/2004 10:33:00 AM

It's not really possible to give a specific answer in 'easy English'
alone,
because Access doesn't understand English - it understands VBA and
SQL. So
here's the answer in both English *and* SQL! :-)

Use the NZ() function to substitute the current date if the payment
date is
NULL.

SELECT NZ([PaymentDate], Date()) AS TheDate FROM SomeTable

In query design view, that would look something like this (in the
'Field'
row)

TheDate: NZ([PaymentDate], Date())

'TheDate' is just a label for the calculated column - you can call it
whatever you like. If you don't give it a label ('alias', in SQL
terminology) Access calls it something like 'Expr1', which isn't
exactly
memorable or enlightening! :-)

--
Brendan Reynolds

"Karen" <kr****@portlite.com> wrote in message
news:50*************************@posting.google.co m...
I need to run a query that will give me the average number of days it
takes a cutomer to pay. I have done this in a select query by
subtracting payment date from invoice date, then averaging, however, I
would like it to use current date if there is no payment history for
the customer or if the customer has an open invoice. How do I
calculate this?

I am not a programmer, so speak in easy english please. :)

Nov 12 '05 #1
2 2772
I would use 2 queries here. The first would work out the payment time taken
for every individual invoice and use Brendon's logic for invoices not paid
and the second would then average the first query.

**Query1 (or what name you call it)**
In the query grid select the following fields from your Invoice table
CustomerID, InvoiceDate, TheDate: NZ([PaymentDate], Date()), DaysToPay:
DateDiff("d", [InvoiceDate], [TheDate])

**Query2**
Create a new query and use Query 1 as the record source and select
CustomerID and DaysToPay into the design grid. Select View>Totals from the
menu and change the Group By under the DaysToPay to Avg.

Stewart
"Karen" <kr****@portlite.com> wrote in message
news:50**************************@posting.google.c om...
I inserted this statement and it worked great for the customers that
have no payment history, but for the customers that have a history and
an open invoice, it still used today's date in the mix and came back
with screwy math. For instance, a customer who actually has an
average payment of 20 days and has an open invoice 12 days old was
calculated at an average of 102 days.... I'm fuzzy, but not that
fuzzy! How do I tell Access to only use today if there is no payment
date as of yet?
Re: Average Payment in Days
From: Brendan Reynolds
Date Posted: 2/11/2004 10:33:00 AM

It's not really possible to give a specific answer in 'easy English'
alone,
because Access doesn't understand English - it understands VBA and
SQL. So
here's the answer in both English *and* SQL! :-)

Use the NZ() function to substitute the current date if the payment
date is
NULL.

SELECT NZ([PaymentDate], Date()) AS TheDate FROM SomeTable

In query design view, that would look something like this (in the
'Field'
row)

TheDate: NZ([PaymentDate], Date())

'TheDate' is just a label for the calculated column - you can call it
whatever you like. If you don't give it a label ('alias', in SQL
terminology) Access calls it something like 'Expr1', which isn't
exactly
memorable or enlightening! :-)

--
Brendan Reynolds

"Karen" <kr****@portlite.com> wrote in message
news:50*************************@posting.google.co m...
I need to run a query that will give me the average number of days it
takes a cutomer to pay. I have done this in a select query by
subtracting payment date from invoice date, then averaging, however, I
would like it to use current date if there is no payment history for
the customer or if the customer has an open invoice. How do I
calculate this?

I am not a programmer, so speak in easy english please. :)

Nov 12 '05 #2
I expect one of the other responses in this thread may solve your problem.
If not, post a reply here and I'll take another look at it.

--
Brendan Reynolds
"Karen" <kr****@portlite.com> wrote in message
news:50**************************@posting.google.c om...
I inserted this statement and it worked great for the customers that
have no payment history, but for the customers that have a history and
an open invoice, it still used today's date in the mix and came back
with screwy math. For instance, a customer who actually has an
average payment of 20 days and has an open invoice 12 days old was
calculated at an average of 102 days.... I'm fuzzy, but not that
fuzzy! How do I tell Access to only use today if there is no payment
date as of yet?
Re: Average Payment in Days
From: Brendan Reynolds
Date Posted: 2/11/2004 10:33:00 AM

It's not really possible to give a specific answer in 'easy English'
alone,
because Access doesn't understand English - it understands VBA and
SQL. So
here's the answer in both English *and* SQL! :-)

Use the NZ() function to substitute the current date if the payment
date is
NULL.

SELECT NZ([PaymentDate], Date()) AS TheDate FROM SomeTable

In query design view, that would look something like this (in the
'Field'
row)

TheDate: NZ([PaymentDate], Date())

'TheDate' is just a label for the calculated column - you can call it
whatever you like. If you don't give it a label ('alias', in SQL
terminology) Access calls it something like 'Expr1', which isn't
exactly
memorable or enlightening! :-)

--
Brendan Reynolds

"Karen" <kr****@portlite.com> wrote in message
news:50*************************@posting.google.co m...
I need to run a query that will give me the average number of days it
takes a cutomer to pay. I have done this in a select query by
subtracting payment date from invoice date, then averaging, however, I
would like it to use current date if there is no payment history for
the customer or if the customer has an open invoice. How do I
calculate this?

I am not a programmer, so speak in easy english please. :)

Nov 12 '05 #3

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

Similar topics

28
by: Steve | last post by:
Hi all How would I find out the average date when given a bunch of dates? For example, I want to find the average length in time from the following dates:...
3
by: Karen | last post by:
I need to run a query that will give me the average number of days it takes a cutomer to pay. I have done this in a select query by subtracting payment date from invoice date, then averaging,...
4
by: inkexit | last post by:
I'd like to know how many sounds I can play at once using the average pc. of course, average is rather vague. let's say, 1 gigahertz, 256 mb ram, and a 16 bit 44.1 khz sound card. the complete...
13
by: Wayne | last post by:
I have just experienced my first late paying client. By "late" I mean that the invoice is now almost 2 months overdue. I don't think that the client is maliciously withholding payment - rather...
3
by: mochatrpl | last post by:
I am looking for a way to make a query / report display the running average for total dollars. I have already set up a query to provide totals dollars per day from which a report graphly shows...
3
by: John Grewar | last post by:
Hello, I have actually asked this before but can't find it on the site (I'm still new here). I have got numerical data coming into my database twice a day for each specific subject that is being...
2
by: Shum | last post by:
Hi ... I'm given the task of keeping a running average of number of patients over 20 days, and plotting it in a graph.. What is basically running average? is it simple average or what.. ? and how...
1
by: suresh_nsnguys | last post by:
Hi guys, i am having this logic regarding payment after usage functionality for my application in my mind. when user login to my application , The popup windiow will be displayed with paypal...
2
by: CodecSmash49 | last post by:
im currently working on a assignment, where you have 3 monkeys that are feed for 7 days. You have to use a 2D array to gather the info. display like a chart, and find the average eaten each day. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.