Compare two Dates

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

I have a table that contains two date fields (DOB & DOD).

I need to add 21 years to DOB and add 7 years to DOD and then compare the
two results and place the most distant result (date) into the Destroy on
Field (located in the same table).
 
I have a table that contains two date fields (DOB & DOD).

I need to add 21 years to DOB and add 7 years to DOD and then compare the
two results and place the most distant result (date) into the Destroy on
Field (located in the same table).

You can determine that information by using an unbound control on a
form.
=IIf IsNull([DOD],"", IIf(DateAdd("yyyy",[DOB])+21 >
DateAdd("yyyy",[DOD])+7, DateAdd("yyyy",[DOB])+21,
DateAdd("yyyy",[DOD])+7))



As long as your table has the [DOB] and the [DOD] data stored, the
above calculation need not be stored in any table.
When you need the information, run the calculation, in a query, on a
report, or in a form.
 
Thanks!

Now where do I put so a long formula?


fredg said:
I have a table that contains two date fields (DOB & DOD).

I need to add 21 years to DOB and add 7 years to DOD and then compare the
two results and place the most distant result (date) into the Destroy on
Field (located in the same table).

You can determine that information by using an unbound control on a
form.
=IIf IsNull([DOD],"", IIf(DateAdd("yyyy",[DOB])+21 >
DateAdd("yyyy",[DOD])+7, DateAdd("yyyy",[DOB])+21,
DateAdd("yyyy",[DOD])+7))



As long as your table has the [DOB] and the [DOD] data stored, the
above calculation need not be stored in any table.
When you need the information, run the calculation, in a query, on a
report, or in a form.
 
I have a table that contains two date fields (DOB & DOD).

I need to add 21 years to DOB and add 7 years to DOD and then compare the
two results and place the most distant result (date) into the Destroy on
Field (located in the same table).

Update DestroyOn to:

IIF(DateAdd("yyyy", 21, [DOB]) > DateAdd("yyyy", 7, [DOD]),
DateAdd("yyyy", 7, [DOD]), DateAdd("yyyy", 21, [DOB]))
 
Thanks!

Now where do I put so a long formula?

fredg said:
I have a table that contains two date fields (DOB & DOD).

I need to add 21 years to DOB and add 7 years to DOD and then compare the
two results and place the most distant result (date) into the Destroy on
Field (located in the same table).

You can determine that information by using an unbound control on a
form.
=IIf IsNull([DOD],"", IIf(DateAdd("yyyy",[DOB])+21 >
DateAdd("yyyy",[DOD])+7, DateAdd("yyyy",[DOB])+21,
DateAdd("yyyy",[DOD])+7))



As long as your table has the [DOB] and the [DOD] data stored, the
above calculation need not be stored in any table.
When you need the information, run the calculation, in a query, on a
report, or in a form.

On a Form, or in a Report, write it as the the control source of an
unbound control.
=IIf IsNull([DOD],"", ...... etc.

In a query add a new column:
DestroyOn:IIf IsNull([DOD],"", ..... etc.

If you do use this in a query, and the query is the record source of a
report or form, then you can just use the [DestroyOn] field in the
report, without having to re-compute it.
 

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

Specify Date to Calculate 1
Query Does Not Pick Up Data 5
Dave Validation Expression 2
Help writing Query 2
subtracting dates 6
Annoying syntax error (missing operator) 10
Compare two dates 2
round a date 6

Back
Top