A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Calculating Dates



 
 
Thread Tools Display Modes
  #11  
Old January 18th, 2007, 08:57 AM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default Calculating Dates

It does have a date field that can be calculated - Peter already showed you
how to do that, which is why I did not reply earlier. You have to set the
date format in the calculation but for that to work reliably the date
entered in the form field has to be a legitimate date. You can help that by
setting the field type to Date. Then

{ IF{Date1 \@ "yyyyMMdd" } {Date2 \@ "yyyyMMdd" } "Greater" "Less" }


There's more on this at 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



Karin wrote:
Peter,

I didn't start out asking the same question. The original question
is why can't word handle dates? I replied to Graham's question of
what I wanted to do.

I still want to know why Word doesn't have a date field that can be
filled in by a user and calculated. I'm clearly not the only one on
this forum wanting to manipulate date information.

Don't assign words or thoughts to me that aren't there. I don't
imagine you're more important than me!

"Peter Jamieson" wrote:

This was my reply to your message in another group - a good example
IMO of why it's not a good idea to post the same question separately
to different groups (in short: why do you imagine that your time is
more valuable than ours?):

The comparisons are text comparisons rather than date comparisons.
To do a date comparison you need the dates in YYYYMMDD format, so
e.g.

{ IF { REF LetterDate \@YYYYMMDD } = { REF YearEndDate \@YYYYMMDD }
"ending" "ended" }

is more likely to do the trick. But of course it will only work if
Word recognises the texts as dates and converts them correctly.


Peter Jamieson



"Karin" wrote in message
...
Graham,

I have two ask fields (LetterDate and YearEndDate). I want to
change text based on the dates:

If LetterDate is = YearEndDate "ending" "ended"

I can have the information entered in the ask fields in any format,
but it needs to be displayed as mmmm dd, yyyy (January 16, 2007) in
the letter.

I'm not much of a programmer, but it doesn't seem like this should
be so difficult.

"Graham Mayor" wrote:

The short answer is that you can do this - if
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 doesn't
give you any
ideas, tell us what you are trying to do.

--

Graham Mayor - Word MVP

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


Karin wrote:
After a lot of searching of this forum, the knowledge base, and
the help files, I can't help but wonder

Why can't Word handle dates?

Why can't I ask a user for different date information and do
calculations on the input?



  #12  
Old January 18th, 2007, 02:34 PM posted to microsoft.public.word.mailmerge.fields
Karin
external usenet poster
 
Posts: 272
Default Calculating Dates

Unfortunately, it doesn't work. The If statement only returns the last part
of the statement (i.e., "less").

ASK Letter Date: {ASK LetterDate "Letter date" \*MERGEFORMAT }

ASK FYE Date: {ASK YEDate "FYE Date" \*MERGEFORMAT }

LetterDate: {REF LetterDate} (January 18, 2007)

YEDate: {REF YEDate} (December 31, 2006)

IF Stmnt: {If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@ "yyyyMMdd"}
"Greater" "Less"}

Should return "Greater", but always, regardless of dates, returns "Less".

So, I'm just going to put another ASK field in and have the user put in the
correct verbiage.

I do appreciate the help, it seems as though it should be so simple.


"Graham Mayor" wrote:

It does have a date field that can be calculated - Peter already showed you
how to do that, which is why I did not reply earlier. You have to set the
date format in the calculation but for that to work reliably the date
entered in the form field has to be a legitimate date. You can help that by
setting the field type to Date. Then

{ IF{Date1 \@ "yyyyMMdd" } {Date2 \@ "yyyyMMdd" } "Greater" "Less" }


There's more on this at 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



Karin wrote:
Peter,

I didn't start out asking the same question. The original question
is why can't word handle dates? I replied to Graham's question of
what I wanted to do.

I still want to know why Word doesn't have a date field that can be
filled in by a user and calculated. I'm clearly not the only one on
this forum wanting to manipulate date information.

Don't assign words or thoughts to me that aren't there. I don't
imagine you're more important than me!

"Peter Jamieson" wrote:

This was my reply to your message in another group - a good example
IMO of why it's not a good idea to post the same question separately
to different groups (in short: why do you imagine that your time is
more valuable than ours?):

The comparisons are text comparisons rather than date comparisons.
To do a date comparison you need the dates in YYYYMMDD format, so
e.g.

{ IF { REF LetterDate \@YYYYMMDD } = { REF YearEndDate \@YYYYMMDD }
"ending" "ended" }

is more likely to do the trick. But of course it will only work if
Word recognises the texts as dates and converts them correctly.


Peter Jamieson



"Karin" wrote in message
...
Graham,

I have two ask fields (LetterDate and YearEndDate). I want to
change text based on the dates:

If LetterDate is = YearEndDate "ending" "ended"

I can have the information entered in the ask fields in any format,
but it needs to be displayed as mmmm dd, yyyy (January 16, 2007) in
the letter.

I'm not much of a programmer, but it doesn't seem like this should
be so difficult.

"Graham Mayor" wrote:

The short answer is that you can do this - if
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 doesn't
give you any
ideas, tell us what you are trying to do.

--

Graham Mayor - Word MVP

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


Karin wrote:
After a lot of searching of this forum, the knowledge base, and
the help files, I can't help but wonder

Why can't Word handle dates?

Why can't I ask a user for different date information and do
calculations on the input?




  #13  
Old January 18th, 2007, 03:04 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Calculating Dates

What results do

{ REF LetterDate \@ "yyyyMMdd" }
and
{ REF YEDate \@ "yyyyMMdd" }

return on their own?

it seems as though it should be so simple.


FWIW, I think most people would agree...

Peter Jamieson
"Karin" wrote in message
...
Unfortunately, it doesn't work. The If statement only returns the last
part
of the statement (i.e., "less").

ASK Letter Date: {ASK LetterDate "Letter date" \*MERGEFORMAT }

ASK FYE Date: {ASK YEDate "FYE Date" \*MERGEFORMAT }

LetterDate: {REF LetterDate} (January 18, 2007)

YEDate: {REF YEDate} (December 31, 2006)

IF Stmnt: {If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@
"yyyyMMdd"}
"Greater" "Less"}

Should return "Greater", but always, regardless of dates, returns "Less".

So, I'm just going to put another ASK field in and have the user put in
the
correct verbiage.

I do appreciate the help, it seems as though it should be so simple.


"Graham Mayor" wrote:

It does have a date field that can be calculated - Peter already showed
you
how to do that, which is why I did not reply earlier. You have to set the
date format in the calculation but for that to work reliably the date
entered in the form field has to be a legitimate date. You can help that
by
setting the field type to Date. Then

{ IF{Date1 \@ "yyyyMMdd" } {Date2 \@ "yyyyMMdd" } "Greater" "Less" }


There's more on this at 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



Karin wrote:
Peter,

I didn't start out asking the same question. The original question
is why can't word handle dates? I replied to Graham's question of
what I wanted to do.

I still want to know why Word doesn't have a date field that can be
filled in by a user and calculated. I'm clearly not the only one on
this forum wanting to manipulate date information.

Don't assign words or thoughts to me that aren't there. I don't
imagine you're more important than me!

"Peter Jamieson" wrote:

This was my reply to your message in another group - a good example
IMO of why it's not a good idea to post the same question separately
to different groups (in short: why do you imagine that your time is
more valuable than ours?):

The comparisons are text comparisons rather than date comparisons.
To do a date comparison you need the dates in YYYYMMDD format, so
e.g.

{ IF { REF LetterDate \@YYYYMMDD } = { REF YearEndDate \@YYYYMMDD }
"ending" "ended" }

is more likely to do the trick. But of course it will only work if
Word recognises the texts as dates and converts them correctly.


Peter Jamieson



"Karin" wrote in message
...
Graham,

I have two ask fields (LetterDate and YearEndDate). I want to
change text based on the dates:

If LetterDate is = YearEndDate "ending" "ended"

I can have the information entered in the ask fields in any format,
but it needs to be displayed as mmmm dd, yyyy (January 16, 2007) in
the letter.

I'm not much of a programmer, but it doesn't seem like this should
be so difficult.

"Graham Mayor" wrote:

The short answer is that you can do this - if
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 doesn't
give you any
ideas, tell us what you are trying to do.

--

Graham Mayor - Word MVP

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


Karin wrote:
After a lot of searching of this forum, the knowledge base, and
the help files, I can't help but wonder

Why can't Word handle dates?

Why can't I ask a user for different date information and do
calculations on the input?






  #14  
Old January 18th, 2007, 04:21 PM posted to microsoft.public.word.mailmerge.fields
Karin
external usenet poster
 
Posts: 272
Default Calculating Dates

{REF LetterDate \@ "yyyyMMdd"} formats the entered date of January 18, 2008,
as 20080118 and the YEDate of December 31, 2006 shows as 20061231, but the
results of the IF statement never changes from "Less" (which is the false
answer).

"Peter Jamieson" wrote:

What results do

{ REF LetterDate \@ "yyyyMMdd" }
and
{ REF YEDate \@ "yyyyMMdd" }

return on their own?

it seems as though it should be so simple.


FWIW, I think most people would agree...

Peter Jamieson
"Karin" wrote in message
...
Unfortunately, it doesn't work. The If statement only returns the last
part
of the statement (i.e., "less").

ASK Letter Date: {ASK LetterDate "Letter date" \*MERGEFORMAT }

ASK FYE Date: {ASK YEDate "FYE Date" \*MERGEFORMAT }

LetterDate: {REF LetterDate} (January 18, 2007)

YEDate: {REF YEDate} (December 31, 2006)

IF Stmnt: {If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@
"yyyyMMdd"}
"Greater" "Less"}

Should return "Greater", but always, regardless of dates, returns "Less".

So, I'm just going to put another ASK field in and have the user put in
the
correct verbiage.

I do appreciate the help, it seems as though it should be so simple.


"Graham Mayor" wrote:

It does have a date field that can be calculated - Peter already showed
you
how to do that, which is why I did not reply earlier. You have to set the
date format in the calculation but for that to work reliably the date
entered in the form field has to be a legitimate date. You can help that
by
setting the field type to Date. Then

{ IF{Date1 \@ "yyyyMMdd" } {Date2 \@ "yyyyMMdd" } "Greater" "Less" }


There's more on this at 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



Karin wrote:
Peter,

I didn't start out asking the same question. The original question
is why can't word handle dates? I replied to Graham's question of
what I wanted to do.

I still want to know why Word doesn't have a date field that can be
filled in by a user and calculated. I'm clearly not the only one on
this forum wanting to manipulate date information.

Don't assign words or thoughts to me that aren't there. I don't
imagine you're more important than me!

"Peter Jamieson" wrote:

This was my reply to your message in another group - a good example
IMO of why it's not a good idea to post the same question separately
to different groups (in short: why do you imagine that your time is
more valuable than ours?):

The comparisons are text comparisons rather than date comparisons.
To do a date comparison you need the dates in YYYYMMDD format, so
e.g.

{ IF { REF LetterDate \@YYYYMMDD } = { REF YearEndDate \@YYYYMMDD }
"ending" "ended" }

is more likely to do the trick. But of course it will only work if
Word recognises the texts as dates and converts them correctly.


Peter Jamieson



"Karin" wrote in message
...
Graham,

I have two ask fields (LetterDate and YearEndDate). I want to
change text based on the dates:

If LetterDate is = YearEndDate "ending" "ended"

I can have the information entered in the ask fields in any format,
but it needs to be displayed as mmmm dd, yyyy (January 16, 2007) in
the letter.

I'm not much of a programmer, but it doesn't seem like this should
be so difficult.

"Graham Mayor" wrote:

The short answer is that you can do this - if
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 doesn't
give you any
ideas, tell us what you are trying to do.

--

Graham Mayor - Word MVP

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


Karin wrote:
After a lot of searching of this forum, the knowledge base, and
the help files, I can't help but wonder

Why can't Word handle dates?

Why can't I ask a user for different date information and do
calculations on the input?






  #15  
Old January 18th, 2007, 04:33 PM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default Calculating Dates

Using your exact example (copied from the messaage with the field boundaries
added) it works fine here?

--

Graham Mayor - Word MVP

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


Karin wrote:
Unfortunately, it doesn't work. The If statement only returns the
last part of the statement (i.e., "less").

ASK Letter Date: {ASK LetterDate "Letter date" \*MERGEFORMAT }

ASK FYE Date: {ASK YEDate "FYE Date" \*MERGEFORMAT }

LetterDate: {REF LetterDate} (January 18, 2007)

YEDate: {REF YEDate} (December 31, 2006)

IF Stmnt: {If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@
"yyyyMMdd"} "Greater" "Less"}

Should return "Greater", but always, regardless of dates, returns
"Less".

So, I'm just going to put another ASK field in and have the user put
in the correct verbiage.

I do appreciate the help, it seems as though it should be so simple.


"Graham Mayor" wrote:

It does have a date field that can be calculated - Peter already
showed you how to do that, which is why I did not reply earlier. You
have to set the date format in the calculation but for that to work
reliably the date entered in the form field has to be a legitimate
date. You can help that by setting the field type to Date. Then

{ IF{Date1 \@ "yyyyMMdd" } {Date2 \@ "yyyyMMdd" } "Greater"
"Less" }


There's more on this at
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



Karin wrote:
Peter,

I didn't start out asking the same question. The original question
is why can't word handle dates? I replied to Graham's question of
what I wanted to do.

I still want to know why Word doesn't have a date field that can be
filled in by a user and calculated. I'm clearly not the only one on
this forum wanting to manipulate date information.

Don't assign words or thoughts to me that aren't there. I don't
imagine you're more important than me!

"Peter Jamieson" wrote:

This was my reply to your message in another group - a good example
IMO of why it's not a good idea to post the same question
separately to different groups (in short: why do you imagine that
your time is more valuable than ours?):

The comparisons are text comparisons rather than date comparisons.
To do a date comparison you need the dates in YYYYMMDD format, so
e.g.

{ IF { REF LetterDate \@YYYYMMDD } = { REF YearEndDate \@YYYYMMDD
} "ending" "ended" }

is more likely to do the trick. But of course it will only work if
Word recognises the texts as dates and converts them correctly.


Peter Jamieson



"Karin" wrote in message
...
Graham,

I have two ask fields (LetterDate and YearEndDate). I want to
change text based on the dates:

If LetterDate is = YearEndDate "ending" "ended"

I can have the information entered in the ask fields in any
format, but it needs to be displayed as mmmm dd, yyyy (January
16, 2007) in the letter.

I'm not much of a programmer, but it doesn't seem like this should
be so difficult.

"Graham Mayor" wrote:

The short answer is that you can do this - if
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 doesn't
give you any
ideas, tell us what you are trying to do.

--

Graham Mayor - Word MVP

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


Karin wrote:
After a lot of searching of this forum, the knowledge base, and
the help files, I can't help but wonder

Why can't Word handle dates?

Why can't I ask a user for different date information and do
calculations on the input?



  #16  
Old January 18th, 2007, 04:35 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Calculating Dates

OK, next step:

If you use Alt-F9 to view the IF field field codes

{If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@ "yyyyMMdd"} "Greater"
"Less"}

then select the first REF field, within the IF, right-click and use "Toggle
field codes", do you still see 20080118?
Then select the second REF field within the IF, right-click and use "Toggle
field codes". Do you still see 20061231?

Peter Jamieson

"Karin" wrote in message
news
{REF LetterDate \@ "yyyyMMdd"} formats the entered date of January 18,
2008,
as 20080118 and the YEDate of December 31, 2006 shows as 20061231, but
the
results of the IF statement never changes from "Less" (which is the false
answer).

"Peter Jamieson" wrote:

What results do

{ REF LetterDate \@ "yyyyMMdd" }
and
{ REF YEDate \@ "yyyyMMdd" }

return on their own?

it seems as though it should be so simple.


FWIW, I think most people would agree...

Peter Jamieson
"Karin" wrote in message
...
Unfortunately, it doesn't work. The If statement only returns the last
part
of the statement (i.e., "less").

ASK Letter Date: {ASK LetterDate "Letter date" \*MERGEFORMAT }

ASK FYE Date: {ASK YEDate "FYE Date" \*MERGEFORMAT }

LetterDate: {REF LetterDate} (January 18, 2007)

YEDate: {REF YEDate} (December 31, 2006)

IF Stmnt: {If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@
"yyyyMMdd"}
"Greater" "Less"}

Should return "Greater", but always, regardless of dates, returns
"Less".

So, I'm just going to put another ASK field in and have the user put in
the
correct verbiage.

I do appreciate the help, it seems as though it should be so simple.


"Graham Mayor" wrote:

It does have a date field that can be calculated - Peter already
showed
you
how to do that, which is why I did not reply earlier. You have to set
the
date format in the calculation but for that to work reliably the date
entered in the form field has to be a legitimate date. You can help
that
by
setting the field type to Date. Then

{ IF{Date1 \@ "yyyyMMdd" } {Date2 \@ "yyyyMMdd" } "Greater"
"Less" }


There's more on this at
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



Karin wrote:
Peter,

I didn't start out asking the same question. The original question
is why can't word handle dates? I replied to Graham's question of
what I wanted to do.

I still want to know why Word doesn't have a date field that can be
filled in by a user and calculated. I'm clearly not the only one on
this forum wanting to manipulate date information.

Don't assign words or thoughts to me that aren't there. I don't
imagine you're more important than me!

"Peter Jamieson" wrote:

This was my reply to your message in another group - a good example
IMO of why it's not a good idea to post the same question
separately
to different groups (in short: why do you imagine that your time is
more valuable than ours?):

The comparisons are text comparisons rather than date comparisons.
To do a date comparison you need the dates in YYYYMMDD format, so
e.g.

{ IF { REF LetterDate \@YYYYMMDD } = { REF YearEndDate
\@YYYYMMDD }
"ending" "ended" }

is more likely to do the trick. But of course it will only work if
Word recognises the texts as dates and converts them correctly.


Peter Jamieson



"Karin" wrote in message
...
Graham,

I have two ask fields (LetterDate and YearEndDate). I want to
change text based on the dates:

If LetterDate is = YearEndDate "ending" "ended"

I can have the information entered in the ask fields in any
format,
but it needs to be displayed as mmmm dd, yyyy (January 16, 2007)
in
the letter.

I'm not much of a programmer, but it doesn't seem like this should
be so difficult.

"Graham Mayor" wrote:

The short answer is that you can do this - if
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 doesn't
give you any
ideas, tell us what you are trying to do.

--

Graham Mayor - Word MVP

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


Karin wrote:
After a lot of searching of this forum, the knowledge base, and
the help files, I can't help but wonder

Why can't Word handle dates?

Why can't I ask a user for different date information and do
calculations on the input?








  #17  
Old January 18th, 2007, 05:01 PM posted to microsoft.public.word.mailmerge.fields
Karin
external usenet poster
 
Posts: 272
Default Calculating Dates

It's working! Bless you! Thank you! Thank you! Thank you!


And it continues to work when I change the date format to be appropriate for
a letter (MMMM DD, YYYY).

"Peter Jamieson" wrote:

OK, next step:

If you use Alt-F9 to view the IF field field codes

{If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@ "yyyyMMdd"} "Greater"
"Less"}

then select the first REF field, within the IF, right-click and use "Toggle
field codes", do you still see 20080118?
Then select the second REF field within the IF, right-click and use "Toggle
field codes". Do you still see 20061231?

Peter Jamieson

"Karin" wrote in message
news
{REF LetterDate \@ "yyyyMMdd"} formats the entered date of January 18,
2008,
as 20080118 and the YEDate of December 31, 2006 shows as 20061231, but
the
results of the IF statement never changes from "Less" (which is the false
answer).

"Peter Jamieson" wrote:

What results do

{ REF LetterDate \@ "yyyyMMdd" }
and
{ REF YEDate \@ "yyyyMMdd" }

return on their own?

it seems as though it should be so simple.

FWIW, I think most people would agree...

Peter Jamieson
"Karin" wrote in message
...
Unfortunately, it doesn't work. The If statement only returns the last
part
of the statement (i.e., "less").

ASK Letter Date: {ASK LetterDate "Letter date" \*MERGEFORMAT }

ASK FYE Date: {ASK YEDate "FYE Date" \*MERGEFORMAT }

LetterDate: {REF LetterDate} (January 18, 2007)

YEDate: {REF YEDate} (December 31, 2006)

IF Stmnt: {If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@
"yyyyMMdd"}
"Greater" "Less"}

Should return "Greater", but always, regardless of dates, returns
"Less".

So, I'm just going to put another ASK field in and have the user put in
the
correct verbiage.

I do appreciate the help, it seems as though it should be so simple.


"Graham Mayor" wrote:

It does have a date field that can be calculated - Peter already
showed
you
how to do that, which is why I did not reply earlier. You have to set
the
date format in the calculation but for that to work reliably the date
entered in the form field has to be a legitimate date. You can help
that
by
setting the field type to Date. Then

{ IF{Date1 \@ "yyyyMMdd" } {Date2 \@ "yyyyMMdd" } "Greater"
"Less" }


There's more on this at
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



Karin wrote:
Peter,

I didn't start out asking the same question. The original question
is why can't word handle dates? I replied to Graham's question of
what I wanted to do.

I still want to know why Word doesn't have a date field that can be
filled in by a user and calculated. I'm clearly not the only one on
this forum wanting to manipulate date information.

Don't assign words or thoughts to me that aren't there. I don't
imagine you're more important than me!

"Peter Jamieson" wrote:

This was my reply to your message in another group - a good example
IMO of why it's not a good idea to post the same question
separately
to different groups (in short: why do you imagine that your time is
more valuable than ours?):

The comparisons are text comparisons rather than date comparisons.
To do a date comparison you need the dates in YYYYMMDD format, so
e.g.

{ IF { REF LetterDate \@YYYYMMDD } = { REF YearEndDate
\@YYYYMMDD }
"ending" "ended" }

is more likely to do the trick. But of course it will only work if
Word recognises the texts as dates and converts them correctly.


Peter Jamieson



"Karin" wrote in message
...
Graham,

I have two ask fields (LetterDate and YearEndDate). I want to
change text based on the dates:

If LetterDate is = YearEndDate "ending" "ended"

I can have the information entered in the ask fields in any
format,
but it needs to be displayed as mmmm dd, yyyy (January 16, 2007)
in
the letter.

I'm not much of a programmer, but it doesn't seem like this should
be so difficult.

"Graham Mayor" wrote:

The short answer is that you can do this - if
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 doesn't
give you any
ideas, tell us what you are trying to do.

--

Graham Mayor - Word MVP

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


Karin wrote:
After a lot of searching of this forum, the knowledge base, and
the help files, I can't help but wonder

Why can't Word handle dates?

Why can't I ask a user for different date information and do
calculations on the input?









  #18  
Old January 18th, 2007, 05:08 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Calculating Dates

Jolly good!

Peter Jamieson

"Karin" wrote in message
...
It's working! Bless you! Thank you! Thank you! Thank you!


And it continues to work when I change the date format to be appropriate
for
a letter (MMMM DD, YYYY).

"Peter Jamieson" wrote:

OK, next step:

If you use Alt-F9 to view the IF field field codes

{If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@ "yyyyMMdd"}
"Greater"
"Less"}

then select the first REF field, within the IF, right-click and use
"Toggle
field codes", do you still see 20080118?
Then select the second REF field within the IF, right-click and use
"Toggle
field codes". Do you still see 20061231?

Peter Jamieson

"Karin" wrote in message
news
{REF LetterDate \@ "yyyyMMdd"} formats the entered date of January 18,
2008,
as 20080118 and the YEDate of December 31, 2006 shows as 20061231, but
the
results of the IF statement never changes from "Less" (which is the
false
answer).

"Peter Jamieson" wrote:

What results do

{ REF LetterDate \@ "yyyyMMdd" }
and
{ REF YEDate \@ "yyyyMMdd" }

return on their own?

it seems as though it should be so simple.

FWIW, I think most people would agree...

Peter Jamieson
"Karin" wrote in message
...
Unfortunately, it doesn't work. The If statement only returns the
last
part
of the statement (i.e., "less").

ASK Letter Date: {ASK LetterDate "Letter date" \*MERGEFORMAT }

ASK FYE Date: {ASK YEDate "FYE Date" \*MERGEFORMAT }

LetterDate: {REF LetterDate} (January 18, 2007)

YEDate: {REF YEDate} (December 31, 2006)

IF Stmnt: {If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@
"yyyyMMdd"}
"Greater" "Less"}

Should return "Greater", but always, regardless of dates, returns
"Less".

So, I'm just going to put another ASK field in and have the user put
in
the
correct verbiage.

I do appreciate the help, it seems as though it should be so simple.


"Graham Mayor" wrote:

It does have a date field that can be calculated - Peter already
showed
you
how to do that, which is why I did not reply earlier. You have to
set
the
date format in the calculation but for that to work reliably the
date
entered in the form field has to be a legitimate date. You can help
that
by
setting the field type to Date. Then

{ IF{Date1 \@ "yyyyMMdd" } {Date2 \@ "yyyyMMdd" } "Greater"
"Less" }


There's more on this at
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



Karin wrote:
Peter,

I didn't start out asking the same question. The original
question
is why can't word handle dates? I replied to Graham's question
of
what I wanted to do.

I still want to know why Word doesn't have a date field that can
be
filled in by a user and calculated. I'm clearly not the only one
on
this forum wanting to manipulate date information.

Don't assign words or thoughts to me that aren't there. I don't
imagine you're more important than me!

"Peter Jamieson" wrote:

This was my reply to your message in another group - a good
example
IMO of why it's not a good idea to post the same question
separately
to different groups (in short: why do you imagine that your time
is
more valuable than ours?):

The comparisons are text comparisons rather than date
comparisons.
To do a date comparison you need the dates in YYYYMMDD format,
so
e.g.

{ IF { REF LetterDate \@YYYYMMDD } = { REF YearEndDate
\@YYYYMMDD }
"ending" "ended" }

is more likely to do the trick. But of course it will only work
if
Word recognises the texts as dates and converts them correctly.


Peter Jamieson



"Karin" wrote in message
...
Graham,

I have two ask fields (LetterDate and YearEndDate). I want to
change text based on the dates:

If LetterDate is = YearEndDate "ending" "ended"

I can have the information entered in the ask fields in any
format,
but it needs to be displayed as mmmm dd, yyyy (January 16,
2007)
in
the letter.

I'm not much of a programmer, but it doesn't seem like this
should
be so difficult.

"Graham Mayor" wrote:

The short answer is that you can do this - if
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 doesn't
give you any
ideas, tell us what you are trying to do.

--

Graham Mayor - Word MVP

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


Karin wrote:
After a lot of searching of this forum, the knowledge base,
and
the help files, I can't help but wonder

Why can't Word handle dates?

Why can't I ask a user for different date information and do
calculations on the input?











  #19  
Old January 21st, 2007, 02:56 AM posted to microsoft.public.word.mailmerge.fields
macropod
external usenet poster
 
Posts: 1,231
Default Calculating Dates

Hi Karin,

Here's a simpler form of the calculation:
{={YEDate \@ yyyyMMdd}-{LetterDate \@ yyyyMMdd} \# ending;ended}

I've been away for a few weeks, so didn't get a chance to contribute earlier.

Cheers

--
macropod
[MVP - Microsoft Word]


"Karin" wrote in message
...
| It's working! Bless you! Thank you! Thank you! Thank you!
|
|
| And it continues to work when I change the date format to be appropriate for
| a letter (MMMM DD, YYYY).
|
| "Peter Jamieson" wrote:
|
| OK, next step:
|
| If you use Alt-F9 to view the IF field field codes
|
| {If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@ "yyyyMMdd"} "Greater"
| "Less"}
|
| then select the first REF field, within the IF, right-click and use
"Toggle
| field codes", do you still see 20080118?
| Then select the second REF field within the IF, right-click and use
"Toggle
| field codes". Do you still see 20061231?
|
| Peter Jamieson
|
| "Karin" wrote in message
| news | {REF LetterDate \@ "yyyyMMdd"} formats the entered date of January 18,
| 2008,
| as 20080118 and the YEDate of December 31, 2006 shows as 20061231, but
| the
| results of the IF statement never changes from "Less" (which is the
false
| answer).
|
| "Peter Jamieson" wrote:
|
| What results do
|
| { REF LetterDate \@ "yyyyMMdd" }
| and
| { REF YEDate \@ "yyyyMMdd" }
|
| return on their own?
|
| it seems as though it should be so simple.
|
| FWIW, I think most people would agree...
|
| Peter Jamieson
| "Karin" wrote in message
| ...
| Unfortunately, it doesn't work. The If statement only returns the
last
| part
| of the statement (i.e., "less").
|
| ASK Letter Date: {ASK LetterDate "Letter date" \*MERGEFORMAT }
|
| ASK FYE Date: {ASK YEDate "FYE Date" \*MERGEFORMAT }
|
| LetterDate: {REF LetterDate} (January 18, 2007)
|
| YEDate: {REF YEDate} (December 31, 2006)
|
| IF Stmnt: {If {REF LetterDate \@ "yyyyMMdd" } {REF YEDate \@
| "yyyyMMdd"}
| "Greater" "Less"}
|
| Should return "Greater", but always, regardless of dates, returns
| "Less".
|
| So, I'm just going to put another ASK field in and have the user put
in
| the
| correct verbiage.
|
| I do appreciate the help, it seems as though it should be so simple.
|
|
| "Graham Mayor" wrote:
|
| It does have a date field that can be calculated - Peter already
| showed
| you
| how to do that, which is why I did not reply earlier. You have to
set
| the
| date format in the calculation but for that to work reliably the
date
| entered in the form field has to be a legitimate date. You can help
| that
| by
| setting the field type to Date. Then
|
| { IF{Date1 \@ "yyyyMMdd" } {Date2 \@ "yyyyMMdd" } "Greater"
| "Less" }
|
|
| There's more on this at
| 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
|
|
|
| Karin wrote:
| Peter,
|
| I didn't start out asking the same question. The original
question
| is why can't word handle dates? I replied to Graham's question of
| what I wanted to do.
|
| I still want to know why Word doesn't have a date field that can
be
| filled in by a user and calculated. I'm clearly not the only one
on
| this forum wanting to manipulate date information.
|
| Don't assign words or thoughts to me that aren't there. I don't
| imagine you're more important than me!
|
| "Peter Jamieson" wrote:
|
| This was my reply to your message in another group - a good
example
| IMO of why it's not a good idea to post the same question
| separately
| to different groups (in short: why do you imagine that your time
is
| more valuable than ours?):
|
| The comparisons are text comparisons rather than date
comparisons.
| To do a date comparison you need the dates in YYYYMMDD format, so
| e.g.
|
| { IF { REF LetterDate \@YYYYMMDD } = { REF YearEndDate
| \@YYYYMMDD }
| "ending" "ended" }
|
| is more likely to do the trick. But of course it will only work
if
| Word recognises the texts as dates and converts them correctly.
|
|
| Peter Jamieson
|
|
|
| "Karin" wrote in message
| ...
| Graham,
|
| I have two ask fields (LetterDate and YearEndDate). I want to
| change text based on the dates:
|
| If LetterDate is = YearEndDate "ending" "ended"
|
| I can have the information entered in the ask fields in any
| format,
| but it needs to be displayed as mmmm dd, yyyy (January 16, 2007)
| in
| the letter.
|
| I'm not much of a programmer, but it doesn't seem like this
should
| be so difficult.
|
| "Graham Mayor" wrote:
|
| The short answer is that you can do this - if
| http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 doesn't
| give you any
| ideas, tell us what you are trying to do.
|
| --
|
| Graham Mayor - Word MVP
|
| My web site www.gmayor.com
| Word MVP web site http://word.mvps.org
|
|
| Karin wrote:
| After a lot of searching of this forum, the knowledge base,
and
| the help files, I can't help but wonder
|
| Why can't Word handle dates?
|
| Why can't I ask a user for different date information and do
| calculations on the input?
|
|
|
|
|
|
|
|
|


  #20  
Old July 1st, 2008, 05:26 PM posted to microsoft.public.word.mailmerge.fields
Bob W
external usenet poster
 
Posts: 88
Default Calculating Dates

Macropod has the calculations perfect, but I need a way of making the setup
of one of his amazing date field calculations, 'user-interactive'. Here's
what I'm trying to do:

A word .doc has a table that shows a proposed event schedule in this format:
Event 1 (notification to proceed [ntp])
Event 2 (ntp+5 days)
Event 3 (ntp+12 days)
etc.

The goal is to let the user type in an initial NTP date in the first row,
and type in various numbers of days in the remaining rows, and then by
refreshing all the fields, the actual calendar dates for all the subsequent
events are automagically calculated and appear in the table.

example of desired results:
Event 1 (notification to proceed [ntp]): January 1, 2009 typed by user)
Event 2 (ntp+5 days): January 6, 2009 (automatically calculated)
Event 3 (ntp+12 days) January 13, 2009 (automatically calculated)

Macropod's calcuation for this, (found in his downloadable DateCalc
document) is entitled, "calculate a day, month and year, using n days delay".
It requires key values in his field calculation formula to be manually
modified by the 'programmer' - how do we make them user-interactive?

"Doug Robbins - Word MVP" wrote:
if you are a field masochist/afficionado like fellow MVP Macropod, you
can do it as shown at:

http://www.wopr.com/cgi-bin/w3t/show...?Number=249902


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:27 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.