473,781 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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****@portlit e.com> wrote in message
news:50******** *************** **@posting.goog le.com...
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 2815
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****@portlit e.com> wrote in message
news:50******** *************** ***@posting.goo gle.com...
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****@portlit e.com> wrote in message
news:50******** *************** **@posting.goog le.com...
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****@portlit e.com> wrote in message
news:50******** *************** ***@posting.goo gle.com...
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****@portlit e.com> wrote in message
news:50******** *************** **@posting.goog le.com...
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
742
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: ---------------------------------------------------- Start Date End Date 01/01/2004 12:50pm 02/01/2004 18:40pm 02/01/2004 13:40pm 02/01/2004 13:57pm 02/01/2004 14:30pm 02/01/2004 19:50pm
3
461
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, 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. :)
4
1750
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 sample library I will be playing back samples from is about 30 MBs total, the individual samples are about 50 KB. if I construct a program from scratch using C to play these sounds, how many could be sounded concurrently?
13
2484
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 there has been an unfortunate series of events which has delayed the payment. The bottom line for a small time developer is still the same however. I am confident that I will receive payment for the invoice eventually but it is now a case of "once...
3
4143
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 the dollars per week. How do I then take the dollars and get a running average for the year? - Randy
3
3446
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 measured. When my project gets going it will continue for > 6 months so it will be a lot of data in the end. I need to create a running average of the numerical data for each subject for the last 7 days. This needs to be a continous evaluation and not...
2
3756
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 can i do it in c# using sql server 2005. i have added the ZedGraph dll into my project.. any help would be highly appreciated.
1
1624
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 button asking user to pay for last month usage with 2 button 'paynow' and 'Remind me' later. when user click 'paynow' button,he will be redirected to paypal for making payment.when user click 'Remind me'.i will remind him when user login next...
2
3127
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. This is the code I have so far. I only need help with displaying it as a chart and finding the average. Please ^.^ #include <cstdlib> #include <iostream> using namespace std;
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10076
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4040
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 we have to send another system
2
3633
muto222
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.