Reply
 
Thread Tools Display Modes
  #1   Report Post  
Judith
 
Posts: n/a
Default How do I compare two dates in Word 2003?

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.
--
Judith
  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

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
"Judith" wrote in message
...
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.
--
Judith



  #3   Report Post  
Judith
 
Posts: n/a
Default

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.
--
Judith


"Doug Robbins" wrote:

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
"Judith" wrote in message
...
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.
--
Judith




  #4   Report Post  
Doug Robbins
 
Posts: n/a
Default

You might find something on comparing dates in Word at:

http://www.wopr.com/cgi-bin/w3t/show...?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
"Judith" wrote in message
...
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.
--
Judith


"Doug Robbins" wrote:

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
"Judith" wrote in message
...
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.
--
Judith






  #5   Report Post  
Graham Mayor
 
Posts: n/a
Default

{IF {MERGEFIELD Date_Paid \@ "yyyyMMdd"} 20050101 "This membership has
expired"
"This membership is current"}

should do the trick - see http://www.gmayor.com/formatting_word_fields.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Judith wrote:
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.





  #6   Report Post  
Judith
 
Posts: n/a
Default

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


"Doug Robbins" wrote:

You might find something on comparing dates in Word at:

http://www.wopr.com/cgi-bin/w3t/show...?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
"Judith" wrote in message
...
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.
--
Judith


"Doug Robbins" wrote:

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
"Judith" wrote in message
...
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.
--
Judith






  #7   Report Post  
Judith
 
Posts: n/a
Default

Thanks Graham - I will try this out as well as Doug's suggestions.
--
Judith


"Graham Mayor" wrote:

{IF {MERGEFIELD Date_Paid \@ "yyyyMMdd"} 20050101 "This membership has
expired"
"This membership is current"}

should do the trick - see http://www.gmayor.com/formatting_word_fields.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Judith wrote:
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.




  #8   Report Post  
Judith
 
Posts: n/a
Default

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.
--
Judith


"Graham Mayor" wrote:

{IF {MERGEFIELD Date_Paid \@ "yyyyMMdd"} 20050101 "This membership has
expired"
"This membership is current"}

should do the trick - see http://www.gmayor.com/formatting_word_fields.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Judith wrote:
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.




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Envelope Address GR New Users 5 April 24th 05 09:48 PM
Comparing Documents in Word 2003 and Word 2002 - VERY Weird Proble Joshua Gray Microsoft Word Help 5 February 18th 05 09:09 PM
copying files from Wordperfect to Microsoft Word Juliet New Users 1 January 31st 05 05:41 PM
WP Delay Code - Word Equiv Mike G - Milw, WI Microsoft Word Help 6 January 10th 05 04:12 PM
How to change merge forms from Word Perfect to Microsoft Word dollfindance Microsoft Word Help 2 December 30th 04 03:35 PM


All times are GMT +1. The time now is 03:31 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"