Group:  Microsoft Word ยป microsoft.public.word.newusers
Thread: Form Field Date Comparison

Geek News

Form Field Date Comparison
Jean D <JeanD[ at ]discussions.microsoft.com> 12/10/2008 6:56:58 PM
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 \[ at ] "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!
Re: Form Field Date Comparison
"macropod" <macropod[ at ]invalid.invalid> 12/10/2008 11:14:26 PM
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 \[ at ] 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.

--
Cheers
macropod
[MVP - Microsoft Word]


"Jean D" <JeanD[ at ]discussions.microsoft.com> wrote in message news:qmb7299m12y2.1f7yehyudt9el$.dlg[ at ]40tude.net...
[Quoted Text]
> 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 \[ at ] "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!

Re: Form Field Date Comparison
"Graham Mayor" <gmayor[ at ]REMOVETHISmvps.org> 12/11/2008 6:21:35 AM
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 \[ at ] "yyyyMMdd" } > 20080701 1 2 }
or
{ If { Field1 \[ at ] "yyyyMMdd" } > 20080701 "1" "2" }


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

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


Jean D wrote:
[Quoted Text]
> 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 \[ at ] "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!


Re: Form Field Date Comparison
Jean D <JeanD[ at ]discussions.microsoft.com> 12/12/2008 1:03:10 AM
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.


On Thu, 11 Dec 2008 08:21:35 +0200, Graham Mayor wrote:

[Quoted Text]
> From: "Graham Mayor" <gmayor[ at ]REMOVETHISmvps.org>
> References: <qmb7299m12y2.1f7yehyudt9el$.dlg[ at ]40tude.net>
> Subject: Re: Form Field Date Comparison
> Date: Thu, 11 Dec 2008 08:21:35 +0200
> Lines: 41
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
> X-RFC2646: Format=Flowed; Original
> Message-ID: <ejjW5i1WJHA.5272[ at ]TK2MSFTNGP04.phx.gbl>
> Newsgroups: microsoft.public.word.newusers
> NNTP-Posting-Host: 213-209-106.netrun.cytanet.com.cy 213.7.209.106
> Path: news.qwest.net!mpls-num-01.inet.qwest.net!mpls-txt-01.inet.qwest.net!feed.news.qwest.net!mpls-nntp-02.inet.qwest.net!news.ecp.fr!feeder.erje.net!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!TK2MSFTFEEDS02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP04.phx.gbl
> Xref: news.qwest.net microsoft.public.word.newusers:25570
>
> 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 \[ at ] "yyyyMMdd" } > 20080701 1 2 }
> or
> { If { Field1 \[ at ] "yyyyMMdd" } > 20080701 "1" "2" }

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net