IF 06/11/2007 > 23/10/2007 = is "True" isn't it?

J

JethroUK©

This is slowly (nay quickly) driving me insane - I have an mailmerge IF
condition to help me spot pending appointments easily

If { MERGEFIELD Myfield \@ "dd/MM/yyyy" } > { DATE \@ "dd/MM/yyyy" } {
MERGEFIELD Myfield \@ "ddd dd MMM hh:mm" } {MERGEFIELD Myfield \@ "dd/MM"}

pseudo = If myfield is after today (pending) then, display mydate in long
date format, else mydate as short date format e.g.:

IF 31/10/2007 > 23/10/2007 = "Wed 31 Oct 07:00" = great

IF 22/10/2007 > 23/10/2007 = "22/10" = great


After a week of (seemingly) no problems - Today I uncovered a gremlin


IF 06/11/2007 > 23/10/2007 is returning "06/11" ????? - that's True isn't
it?


I have always had problems getting MS Word (XP 2002) to interpret UK/English
dates - I thought after DDE connection (albeit it very incovenient) my
troubles were over
Just looking at these examples myself (as i type here) I can see that
despite 06/11/2007 displayed in full, formatted correctly (UK day/month),
interpreted (from XL) & displayed correctly, connected as DDE - this is
'still' just a fudge for the folks over in blighty - it is clearly evident
that MS Word 'still' thinks this is US 11th June 2007 & i am about to try
few more dates to confirm it

Is it fair to say MS Word just doesn't know what day it is? Or am I missing
something obvious or do I give up gracefully?
 
J

Jay Freedman

Hi Jethro,

What you're missing is that Word fields don't do date arithmetic. The
results of the two internal fields beign compared here are _strings_ and the
"greater than" comparison is doing an alphanumeric comparison of those
strings. So whenever the day number of the merge field is less than the day
number of today -- in your example, "06" is alphanumerically less than
"23" -- the result of the comparison is False. It has nothing to do with US
vs. UK or what Word "thinks" of the date.

The only reliable way to express dates so they can be compared
alphanumerically is with the format "yyyyMMdd", in decreasing unit order.
Try rewriting the first part of your field as

If { MERGEFIELD Myfield \@ "yyyyMMdd" } > { DATE \@ "yyyyMMdd" }

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
J

JethroUK©

Brilliant! - Oh what a clever chap you are - it makes so much sense too -
thanks thanks thanks

I can now get on with the rest of my life - Thankyooooooooooooooooooo!!!!!!!
 
J

JethroUK©

In early help with this very IF function, Peter, Graham & indeed yourself
posted this very same date syntax for comparison, but for some reason i was
so tied into the function i completely failed to even notice the format or
the significance of year/month/day - so for that i extend my thanks & i'll
check out the articles


macropod said:
Hi Jethro

Just in case you need to do anything more esoteric with dates in Word,
check out my Date Calc 'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902
or
http://www.gmayor.com/downloads.htm#Third_party

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

JethroUK© said:
Brilliant! - Oh what a clever chap you are - it makes so much sense too -
thanks thanks thanks

I can now get on with the rest of my life -
Thankyooooooooooooooooooo!!!!!!!
 

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