How do I compare two dates in Word 2003?

J

Judith

I want to compare a MERGEFIELD date that has been extracted from an Access
database with a typed in value as part of an If...then...else statement. For
example, if the Date_Paid field is less than 01/01/2005 I want to insert text
to say that the person's membership has expired.

The syntax I came up with is
{IF {MERGEFIELD Date_Paid} < 01/01/2005 "This membership has expired" "This
membership is current"}
but it doesn't work. I have also tried adding a date pattern of \@
dd/MM\yyyy, and using quotes around the coparison date.

I am using Word 2003.
 
D

Doug Robbins

I would do the manipulation of the data with a query in Access.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Judith

I'm not exactly sure what you mean as I'm not very experienced with Access.
Are you indicating that Word can't actually compare dates? I have today tried
using the COMPARE function, but that seems to work only with strings and
numbers and the Help doesn't mention dates.
 
D

Doug Robbins

You might find something on comparing dates in Word at:

http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902

I think though that in Word, you will find it necessary to use a number of
nested If...then...else statements that separately compare the day, the
month and the year, whereas in Access, in a query you simply use

IIF([Date_Paid] < #01/01/2005#, "This membership has expired", "This
membership is current")

Learn to use the power of Access.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Judith

Thanks Doug. I will follow up both of these suggestions and let you know how
I get on.
--
Judith


Doug Robbins said:
You might find something on comparing dates in Word at:

http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902

I think though that in Word, you will find it necessary to use a number of
nested If...then...else statements that separately compare the day, the
month and the year, whereas in Access, in a query you simply use

IIF([Date_Paid] < #01/01/2005#, "This membership has expired", "This
membership is current")

Learn to use the power of Access.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Judith

Brilliant - it works exactly how I wanted it to (once I had remembered that I
needed to do MM rather than mm for the month!) Thanks a lot for the
suggestion.
 

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