View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Jules[_2_] Jules[_2_] is offline
external usenet poster
 
Posts: 8
Default if statements with dates in mailmerge

On 6 apr, 20:03, "Peter Jamieson"
wrote:
What fields are you using to do the comparison?

If you are doing something like

{ IF { REF EndDate } = { REF StartDate } "equal" "different" }

you need to do something more like

{ IF "{ REF EndDate }" = "{ REF StartDate }" "equal" "different" }

(I don't know whyWordneeds the quotes in this case) and in any case you
really need to format the dates as YYYYMMDD before you compare them (which
you may be doing) but you can try

{ ={ REF EndDate \@YYYYMMDD }-{REF StartDate \@YYYYMMDD }
\#"'{ REF StartDate \@"M/D" }-{ REF EndDate \@"M/D/YYYY" }';'x';'{ REF
StartDate \@"M/D/YYYY" }'" }

and put something instead of "x" if you need to cover the case where the
start date is after the end date.

If you're using MERGEFIELD fields, some of the above may not apply but you
still need the YYYYMMDD stuff.

Peter Jamieson



walkerh wrote in ...
This has me puzzled. We have a mailmerge document populated from an
external database via aheaderand text file. In the letter we compare a
Start Date with an End Date. If they are the same the letter only prints
the Start Date m/d/y. If the End Date is greater than the Start Date, we
format the Start Date for month/day add a dash and format the End Date
month/day/year. We just ran into a case where if the month and day are
the same in the Start Date and the same in the End Date the test fails and
only the Start Date is printed. An example would be SD = 04/04/2007 and
ED = 06/06/2007. changing the SD to 03/03/2007 or 05/05/2007 or the ED in
similiar fashion yields the same failure. A difference in the year
results in the desired behavior. Any thoughts?


EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -


it could help you a lot by using a query containing this sort of
inteligence. I think the formula mentioned will work (except the
quotes around a field, I shouldn't use those). But a query is much
more easy to design.
If your external database doesn't allow to make queries, you could
export the data to a Excel or beter Access file.
Good luck