Calculation based on Date

J

Jamie

I am working in Word 2002.

I’m creating a travel claim. Two different mileage reimbursements can
apply, depending on the date the mileage was incurred.

For mileage before 12/31/05 the reimbursement rate is 0.485.
Mileage after 12/31/05 the reimbursement rate is 0.445

I have a date field (text1), then a filed for the amount of miles traveled
(text2), then a field in which I want either 0.485 or 0.445 to show (text3),
depending on the date in the date field.

Not sure how to go about the coding for this. I've been trying to do the
calculation within the field properties, but can't figure out the coding for
the date. Any assistance will be appreciated.

Thanks!
 
K

Karl E. Peterson

Jamie said:
I am working in Word 2002.

I’m creating a travel claim. Two different mileage reimbursements
can apply, depending on the date the mileage was incurred.

For mileage before 12/31/05 the reimbursement rate is 0.485.
Mileage after 12/31/05 the reimbursement rate is 0.445

I have a date field (text1), then a filed for the amount of miles
traveled (text2), then a field in which I want either 0.485 or 0.445
to show (text3), depending on the date in the date field.

Not sure how to go about the coding for this. I've been trying to do
the calculation within the field properties, but can't figure out
the coding for the date. Any assistance will be appreciated.

Q&D:

If CDate(Text1.Text) >= #12/31/2005# Then
Rate = 0.485
Else
Rate = 0.445
End If
Text3.Text = Format$(Rate, "$0.000")

Some error checking may be required, to accomodate your peskier users.
 
T

Tony Jollans

This is made easier by the comparand being the end of a year.

Set your date field to Calculate on Exit and then add a Field (not a
FormField) like this ...

{ If { Text1 \@ yyyy } > 2005 0.445 0.485 }

Or, if you need to reference this later, you'll need to set, say, Text3, to
the value ...

{ Set Text3 { If { Text1 \@ yyyy } > 2005 0.445 0.485 } }

(note this is instead of having a FormField called Text3)
 
G

Graham Mayor

If it wasn't at the end of the year you could still use the same method,
only the switch would be different :)

eg { If { Text1 \@ yyyyMMdd } > 20051231 0.445 0.485 }


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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