Date function query

Nunzie23

Board Regular
Joined
Feb 22, 2007
Messages
152
HI! Thanks in advance to anyone who can offer some help with this.

In a very simple database I have a field (referral date) and another one (1st appointment) which I need a calculation for. Basically I want to create an additional field that tells me in months and days how long a person was waiting between the date they were referred and the date of the 1st appointment.

If they actually haven't received a 1st appointment yet and the 1st appointment field is blank I would like it to calculate the waiting time so far with the the current date.

I think it's something like [1st appointment] - [referral date] but i'm not sure how to add the if function if the 1st appointment field is blank. And do I put this in the query itself? or in the report, etc.

Thanks again for the help.
 
Nunzie;
Let's try a new approach. I suspect that Access is having difficulty with the " " to represent a null field.

Try this:

=iif(NZ([Date of 1st Appt],Date()),DateDiff("d",Date(),[Date of 1st Appt]),DateDiff("d",[Date of Referral],[Date of 1st appt]))

In this scenario, we added the NZ function that says if the Date of 1st Appt is null, then use the current date.

Post back with your results.

Alan
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
For the number of days between two dates, you can also subtract:

Code:
=NZ([Date of 1st appt],Date())-[Date of Referral])
 
Upvote 0
Xenou;
Excellent addition. I got so wrapped in the =IIF statement that I missed the forest for the trees.

Alan
 
Upvote 0
It may be that I have a blind spot for DateDiff as for some reason I almost never use it ... missing forest for trees, I guess. :) I also seemed to overlook Domain Aggregate functions for a very long time until the last year or so.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top