DateDiff and Count/Sum

C

caro

I am trying to count records where the scheduled date is greater than the
current date. All Dates (past visits and scheduled visits) are listed in the
Date of Awareness field. The expressions I have tried include:
=IIF(DateDiff("d", [Date of Awareness], Date()>1,1,0))
=Abs(Sum([Date of Awareness]> Date()))
Please let me know if I am even on the right track.
-Caro
 
J

Jeff Boyce

Where are you doing this? In a query?

Could you use a query, include the [Date of Awareness] field, and in the
criteria, use something like (untested):

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

caro said:
I am trying to count records where the scheduled date is greater than the
current date. All Dates (past visits and scheduled visits) are listed in
the
Date of Awareness field. The expressions I have tried include:
=IIF(DateDiff("d", [Date of Awareness], Date()>1,1,0))
=Abs(Sum([Date of Awareness]> Date()))
Please let me know if I am even on the right track.
-Caro
 
D

Duane Hookom

What was the result for
=Abs(Sum([Date of Awareness]> Date()))
Where did you enter this? What section of the report?
 
K

KARL DEWEY

Your =IIF(DateDiff("d", [Date of Awareness], Date()>1,1,0))
has closing parenthesis misplaced like this --
=IIF(DateDiff("d", [Date of Awareness], Date())>1,1,0)

Your =Abs(Sum([Date of Awareness]> Date()))
is missing an IIF like this --
=Abs(Sum(IIF([Date of Awareness]> Date(), 1, 0)))
and it does not need the Abs function.
 
D

Duane Hookom

Karl,
Aren't these the same:
=Abs(Sum([Date of Awareness]> Date()))
=Abs(Sum(IIF([Date of Awareness]> Date(), 1, 0)))

This expression will return -1 for true or 0 for false
[Date of Awareness]> Date()

If you Sum() this expression, it will return a negative count of the number
of records that return true.

Changing the negative to positive with Abs() should provide the same value
as your suggestion. Or, did I miss something?

--
Duane Hookom
Microsoft Access MVP


KARL DEWEY said:
Your =IIF(DateDiff("d", [Date of Awareness], Date()>1,1,0))
has closing parenthesis misplaced like this --
=IIF(DateDiff("d", [Date of Awareness], Date())>1,1,0)

Your =Abs(Sum([Date of Awareness]> Date()))
is missing an IIF like this --
=Abs(Sum(IIF([Date of Awareness]> Date(), 1, 0)))
and it does not need the Abs function.

--
Build a little, test a little.


caro said:
I am trying to count records where the scheduled date is greater than the
current date. All Dates (past visits and scheduled visits) are listed in the
Date of Awareness field. The expressions I have tried include:
=IIF(DateDiff("d", [Date of Awareness], Date()>1,1,0))
=Abs(Sum([Date of Awareness]> Date()))
Please let me know if I am even on the right track.
-Caro
 
K

KARL DEWEY

You did not miss anything, I just do not know a lot of things.
--
Build a little, test a little.


Duane Hookom said:
Karl,
Aren't these the same:
=Abs(Sum([Date of Awareness]> Date()))
=Abs(Sum(IIF([Date of Awareness]> Date(), 1, 0)))

This expression will return -1 for true or 0 for false
[Date of Awareness]> Date()

If you Sum() this expression, it will return a negative count of the number
of records that return true.

Changing the negative to positive with Abs() should provide the same value
as your suggestion. Or, did I miss something?

--
Duane Hookom
Microsoft Access MVP


KARL DEWEY said:
Your =IIF(DateDiff("d", [Date of Awareness], Date()>1,1,0))
has closing parenthesis misplaced like this --
=IIF(DateDiff("d", [Date of Awareness], Date())>1,1,0)

Your =Abs(Sum([Date of Awareness]> Date()))
is missing an IIF like this --
=Abs(Sum(IIF([Date of Awareness]> Date(), 1, 0)))
and it does not need the Abs function.

--
Build a little, test a little.


caro said:
I am trying to count records where the scheduled date is greater than the
current date. All Dates (past visits and scheduled visits) are listed in the
Date of Awareness field. The expressions I have tried include:
=IIF(DateDiff("d", [Date of Awareness], Date()>1,1,0))
=Abs(Sum([Date of Awareness]> Date()))
Please let me know if I am even on the right track.
-Caro
 
D

Duane Hookom

Karl,
I have learned a lot from your past posts so I was a bit concerned I had
messed up the syntax/expression.

--
Duane Hookom
Microsoft Access MVP


KARL DEWEY said:
You did not miss anything, I just do not know a lot of things.
--
Build a little, test a little.


Duane Hookom said:
Karl,
Aren't these the same:
=Abs(Sum([Date of Awareness]> Date()))
=Abs(Sum(IIF([Date of Awareness]> Date(), 1, 0)))

This expression will return -1 for true or 0 for false
[Date of Awareness]> Date()

If you Sum() this expression, it will return a negative count of the number
of records that return true.

Changing the negative to positive with Abs() should provide the same value
as your suggestion. Or, did I miss something?

--
Duane Hookom
Microsoft Access MVP


KARL DEWEY said:
Your =IIF(DateDiff("d", [Date of Awareness], Date()>1,1,0))
has closing parenthesis misplaced like this --
=IIF(DateDiff("d", [Date of Awareness], Date())>1,1,0)

Your =Abs(Sum([Date of Awareness]> Date()))
is missing an IIF like this --
=Abs(Sum(IIF([Date of Awareness]> Date(), 1, 0)))
and it does not need the Abs function.

--
Build a little, test a little.


:

I am trying to count records where the scheduled date is greater than the
current date. All Dates (past visits and scheduled visits) are listed in the
Date of Awareness field. The expressions I have tried include:
=IIF(DateDiff("d", [Date of Awareness], Date()>1,1,0))
=Abs(Sum([Date of Awareness]> Date()))
Please let me know if I am even on the right track.
-Caro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top