473,287 Members | 1,926 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,287 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 2764
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.