Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
{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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Envelope Address | New Users | |||
Comparing Documents in Word 2003 and Word 2002 - VERY Weird Proble | Microsoft Word Help | |||
copying files from Wordperfect to Microsoft Word | New Users | |||
WP Delay Code - Word Equiv | Microsoft Word Help | |||
How to change merge forms from Word Perfect to Microsoft Word | Microsoft Word Help |