Form Field Date Comparison

  • Thread starter Thread starter Jean D
  • Start date Start date
J

Jean D

In Word 2007, I have a form with fields. I have the user enter a date in
Field1 and then want Field2 to do certain things based on whether the date
in Field1 is greater than a static date. I read a great example from
Graham Mayor that works, but when I try to change the date format from the
example, it won't work.

Works:
Format Field1 as a yyyyMMdd date
Field2: =If (Field1 \@ "yyyyMMdd" > 20080701, 1, 2)

This is great, but it makes Field1 show up as 20081210, when I would like
it to show up as 12/10/08.

Is there a way to do a date comparison and still have Field1 display a date
in the M/D/YY format?

Thanks for any help!
 
Hi Jean,

You could leave Field1 in 'D M YYYY' format or 'M D YYYY' format (or whichever variant of those you prefer. You could then use a
formula field (not a formfield) to do the comparison using the following syntax:
{IF{Field1 \@ YYYYMMDD}> 20080701 "1" "2"}

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste
them from this message.
 
I don't recall suggesting that you should format Field1 as yyyyMMdd? It is
in the conditional field where it needs to be so formatted. Field1 can use
any valid date format you require at the point of its display.
See http://www.gmayor.com/formatting_word_fields.htm
If thgis is a protected form and Field1 is a text form field with its
properties set as Date with the format M/d/yy (or d/M/yy) then the second
field should be a Word field combination (not a form field)
{ If { Field1 \@ "yyyyMMdd" } > 20080701 1 2 }
or
{ If { Field1 \@ "yyyyMMdd" } > 20080701 "1" "2" }


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Thank you both for your help! This works perfectly. I now see that I am
having a newbie confusion between calculated form fields and formula
fields. They seemed to have the same functionality, but now I am beginning
to see that they don't. I also realize now that this confustion caused me
to misread your (Graham) example that I found earlier. I'll see if I can
find any reference to help me understand when to use one or the other.

Thank you both again so much!

J.
 
Back
Top