Null and Dates

S

Sharon

I use the following calculation to determine the amount of
months between the [last_review_date] and the
[next_review_date].

Cycle: DateDiff("m", [next_review_date],
[last_review_date])

Where does the Nz go in this calculation for records that
do not have both dates yet?
 
C

Chuck Minarik

Try this:

If ((nz([next_review_date], 0) <> 0) AND _
(nz([last_review_date], 0) <> 0)) Then

Cycle: DateDiff("m", [next_review_date], _
[last_review_date])
End If

Good Luck,

Chuck
 
G

Guest

Chuck,
Should this code go into a query or into VB?


-----Original Message-----
Try this:

If ((nz([next_review_date], 0) <> 0) AND _
(nz([last_review_date], 0) <> 0)) Then

Cycle: DateDiff("m", [next_review_date], _
[last_review_date])
End If

Good Luck,

Chuck
-----Original Message-----
I use the following calculation to determine the amount of
months between the [last_review_date] and the
[next_review_date].

Cycle: DateDiff("m", [next_review_date],
[last_review_date])

Where does the Nz go in this calculation for records that
do not have both dates yet?
.
.
 
C

Chuck Minarik

The way I originally answered would go in VB.

If you want to do it in a Query, add a column for each date
like so:

Expr1: nz([next_review_date], 0) and
Expr2: nz([last_review_date], 0)

In the Criteria row below each of these columns, add the
criteria:

<> 0

Then your original column for Cycle should compute just
fine.

Chuck
-----Original Message-----
Chuck,
Should this code go into a query or into VB?


-----Original Message-----
Try this:

If ((nz([next_review_date], 0) <> 0) AND _
(nz([last_review_date], 0) <> 0)) Then

Cycle: DateDiff("m", [next_review_date], _
[last_review_date])
End If

Good Luck,

Chuck
-----Original Message-----
I use the following calculation to determine the amount of
months between the [last_review_date] and the
[next_review_date].

Cycle: DateDiff("m", [next_review_date],
[last_review_date])

Where does the Nz go in this calculation for records that
do not have both dates yet?
.
.
.
 
J

John Vinson

I use the following calculation to determine the amount of
months between the [last_review_date] and the
[next_review_date].

Cycle: DateDiff("m", [next_review_date],
[last_review_date])

Where does the Nz go in this calculation for records that
do not have both dates yet?

What answer do you want if one of these dates is unknown? How many
months are there between #1/29/2004# and (Unspecified date)? I don't
think it makes any sense to do this calculation at all unless you know
both dates; can you just put a criterion of IS NOT NULL on the two
fields so that you only calculate a value if they are known?
 

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

Similar Threads

Dates and Null 2
Null Dates 1
Refresh fields with dlookup 1
Help with small result type 2
IIf statement in Access 2003 query 9
DateDiff Null Values 2
NZ in null date 1
Cycle Time 1

Top