Reply
 
Thread Tools Display Modes
  #1   Report Post  
Barb Reinhardt
 
Posts: n/a
Default Setting Dates in Word - first and last day of previous month

Can someone direct me to some code to calculate the first and last day of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt


  #2   Report Post  
macropod
 
Posts: n/a
Default

Hi Barb,

For a field-code solution, download the Word document at:
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902
(url all one line)
That document contains a tutorial for doing a wide range of date/time
calculations in Word, including some of the kind you're after.

If you need it, there are macro-based solutions also that I'm sure one of
the other contributors here could post.

Cheers


"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last day of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt




  #3   Report Post  
Barb Reinhardt
 
Posts: n/a
Default

I believe I looked at that yesterday and had limited success. I can't seem
to open it today. Are there any tutorials for field codes and how to do
calculations, etc. with them? I haven't been able to find any.

Thanks for your assistance.

"macropod" wrote in message
...
Hi Barb,

For a field-code solution, download the Word document at:
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902
(url all one line)
That document contains a tutorial for doing a wide range of date/time
calculations in Word, including some of the kind you're after.

If you need it, there are macro-based solutions also that I'm sure one of
the other contributors here could post.

Cheers


"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last day

of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt






  #4   Report Post  
Barb Reinhardt
 
Posts: n/a
Default

Let me ask a couple of more specific questions. I want to create several
date fields. They need to work for the following two circumstances.

1) If the CREATE DATE is any day in January 2005, how do I create the
following:
1st field: First date of previous month in format 12/1/2004
2nd field: Last date of previous month in format 12/31/2004
3rd field: Last date of prevous month in format December 31, 2004
4th field: Year portion of previous month in format 2004.
2) If the CREATE DATE is December 2004, how do I create:
1st field: First date of previous month in format 11/1/2004
2nd field: Last date of previous month in format 11/31/2004
3rd field: Last date of prevous month in format November 30, 2004
4th field: Year portion of previous month in format 2004.





"macropod" wrote in message
...
Hi Barb,

For a field-code solution, download the Word document at:
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902
(url all one line)
That document contains a tutorial for doing a wide range of date/time
calculations in Word, including some of the kind you're after.

If you need it, there are macro-based solutions also that I'm sure one of
the other contributors here could post.

Cheers


"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last day

of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt






  #5   Report Post  
Barb Reinhardt
 
Posts: n/a
Default

I have the following as field codes

{ =IF( { CREATEDATE \@ "MM" } = 01 { CREATEDATE \@ "yyyy" } { = { CREATEDATE \@ "yyyy" }+1 \# "0000"} ) }



Everything in RED is working, but I can't get the IF statement to work. What am I doing wrong?



"Barb Reinhardt" wrote in message ...
Can someone direct me to some code to calculate the first and last day of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt




  #6   Report Post  
Charles Kenyon
 
Posts: n/a
Default

IF does not use parentheses in Word

{ =IF { CREATEDATE \@ "MM" } = 01 { CREATEDATE \@ "yyyy" } { = { CREATEDATE
\@ "yyyy" }+1 \# "0000"} }

For additional samples of IF statements in dates look at
http://addbalance.com/word/datefields2.htm.
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

"Barb Reinhardt" wrote in message
...
I have the following as field codes

{ =IF( { CREATEDATE \@ "MM" } = 01 { CREATEDATE \@ "yyyy" } { = { CREATEDATE
\@ "yyyy" }+1 \# "0000"} ) }



Everything in RED is working, but I can't get the IF statement to work.
What am I doing wrong?



"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last day of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt




  #7   Report Post  
Graham Mayor
 
Posts: n/a
Default

I think you are trying to do the following:

{ IF { CREATEDATE \@ "MM" } = "01" "{ CREATEDATE \@ "yyyy" }" "{ =({
CREATEDATE \@ "yyyy" }+1) \# "0000" }"}

ie for January you want this year, for other months next year

--

Graham Mayor - Word MVP

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





"Barb Reinhardt" wrote in message
...
I have the following as field codes

{ =IF( { CREATEDATE \@ "MM" } = 01 { CREATEDATE \@ "yyyy" } { = { CREATEDATE
\@ "yyyy" }+1 \# "0000"} ) }

Everything in RED is working, but I can't get the IF statement to work.
What am I doing wrong?

"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last day of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt




  #8   Report Post  
Barb Reinhardt
 
Posts: n/a
Default

I've tried both of them and I still get a syntax error.

"Graham Mayor" wrote in message
...
I think you are trying to do the following:

{ IF { CREATEDATE \@ "MM" } = "01" "{ CREATEDATE \@ "yyyy" }" "{ =({
CREATEDATE \@ "yyyy" }+1) \# "0000" }"}

ie for January you want this year, for other months next year

--

Graham Mayor - Word MVP

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





"Barb Reinhardt" wrote in message
...
I have the following as field codes

{ =IF( { CREATEDATE \@ "MM" } = 01 { CREATEDATE \@ "yyyy" } { = {

CREATEDATE
\@ "yyyy" }+1 \# "0000"} ) }

Everything in RED is working, but I can't get the IF statement to work.
What am I doing wrong?

"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last day

of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt






  #9   Report Post  
Barb Reinhardt
 
Posts: n/a
Default

I have resolved some of the field codes and I get this:

{ =IF 12 = "01" "2004" "2005"}



But when I try to update the field, I get this:



!Syntax Error, 12



"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last day of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt




  #10   Report Post  
Charles Kenyon
 
Posts: n/a
Default

If in doubt, add quotation marks. Try
{ =IF "12" = "01" "2004" "2005"}

I am assuming that the 12 is generated by some other field. I haven't been
following the entire thread.
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

"Barb Reinhardt" wrote in message
...
I have resolved some of the field codes and I get this:




But when I try to update the field, I get this:



!Syntax Error, 12



"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last day of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt








  #11   Report Post  
Graham Mayor
 
Posts: n/a
Default

It works fine here - are you setting all the field boundaries {} using
CTRL+F9 or are you simply typing them

--

Graham Mayor - Word MVP

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




Barb Reinhardt wrote:
I've tried both of them and I still get a syntax error.

"Graham Mayor" wrote in message
...
I think you are trying to do the following:

{ IF { CREATEDATE \@ "MM" } = "01" "{ CREATEDATE \@ "yyyy" }" "{ =({
CREATEDATE \@ "yyyy" }+1) \# "0000" }"}

ie for January you want this year, for other months next year

--

Graham Mayor - Word MVP

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





"Barb Reinhardt" wrote in message
...
I have the following as field codes

{ =IF( { CREATEDATE \@ "MM" } = 01 { CREATEDATE \@ "yyyy" } { = {
CREATEDATE \@ "yyyy" }+1 \# "0000"} ) }

Everything in RED is working, but I can't get the IF statement to
work. What am I doing wrong?

"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last
day of the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt



  #12   Report Post  
Graham Mayor
 
Posts: n/a
Default

The = sign is not required in front of the IF

--

Graham Mayor - Word MVP

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




Barb Reinhardt wrote:
I have resolved some of the field codes and I get this:

{ =IF 12 = "01" "2004" "2005"}



But when I try to update the field, I get this:



!Syntax Error, 12



"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last
day of the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt



  #13   Report Post  
Barb Reinhardt
 
Posts: n/a
Default

I had to add commas to get it to work. I reviewed some of the examples
from a link posted by macropod and went from there. Thanks for your help
on this one.
"Barb Reinhardt" wrote in message
...
Can someone direct me to some code to calculate the first and last day of
the previous month to be used in an Invoice?

Thanks in advance,
Barb Reinhardt




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:51 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"