Formula for number of days elapsed?

R

Roger Tregelles

Hi Folks,

I have a word document with a table that I use to track open reports. In one
of the columns I have the date the report was issued and in another column I
report the aging of the report by manually calculating the number of days
from the date the report was issued to the current date. I would like to use
a formula like you can do so in Excel to do this automatically. I assumed I
would use a formula like this: NOW() - H2. However when I tried that I got a
syntax error. Any ideas on what I am doing wrong in constructing this
formula? Also, is there a easy way to tell what cell you are currently
working in? Any and all help will be greatly appreciated.

Roger Tregelles
Quality Assurance Engineer
Respironics Inc.
 
M

macropod

Hi Roger,

Word's equivalent to Excel's NOW() function is a DATE field. However, even with that you can't simply use something like
{={DATE}-H2}.

To see how to do this calculation and just about everything else you might want to do with dates in Word, check out my Date Calc
'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902
In particular, look at the items titled 'Calculate the # Days Difference Between Two Dates' and 'Date Calculations in a Table'.

Cheers

--
macropod
[MVP - Microsoft Word]


| Hi Folks,
|
| I have a word document with a table that I use to track open reports. In one
| of the columns I have the date the report was issued and in another column I
| report the aging of the report by manually calculating the number of days
| from the date the report was issued to the current date. I would like to use
| a formula like you can do so in Excel to do this automatically. I assumed I
| would use a formula like this: NOW() - H2. However when I tried that I got a
| syntax error. Any ideas on what I am doing wrong in constructing this
| formula? Also, is there a easy way to tell what cell you are currently
| working in? Any and all help will be greatly appreciated.
|
| Roger Tregelles
| Quality Assurance Engineer
| Respironics Inc.
|
|
 
R

Roger Tregelles

Macropod,

Thanks for getting back to me and the link to your tutorial. I downloaded it
and read it through but am stuck on how exactly to actually do what you talk
about in the document. For example the document states the following:

"One of the limitations of Word's formula handling in tables is its
inability to evaluate text strings, including dates. To get around this, you
need to bookmark the contents of the affected cells (not the cells
themselves) and reference those bookmarks (instead of the cells) in the
formulae. The following table demonstrates how to do this using ASK fields
to create the bookmarks:"

I have no idea how to bookmark the contents of a cell and use ASK fields to
accomplish what I need to do. Could you please point me to somewhere on how
exactly I would go about doing this. Thanks so much for your help with this.

Roger
 
G

Graham Mayor

ASK fields are simply a way of gathering information to be saved in a
bookmark. If you are working with already entered data you don't need the
ASK fields
In this instance you select the date content of the cell and assign it to a
bookmark - Insert > Bookmark - and name it to match the field construction
i.e. StartDate
As you are comparing this with today's date, you can change the EndDate ref
field in the first item on page 9 - Calculate the # Days Difference Between
Two Dates - to a DATE field thus :

{={SET a{=INT((14-{Date \@ M})/12)}}{SET b{={Date \@ yyyy}+4800-a}}{SET
c{={Date \@ M}+12*a-3}}{SET d{Date \@
d}}{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045}-{SET
a{=INT((14-{StartDate \@ M})/12)}}{SET b{={StartDate \@ yyyy}+4800-a}}{SET
c{={StartDate \@ M}+12*a-3}}{SET d{StartDate \@
d}}{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045}\# ,0}

Thus with startdate being the date of your report eg
StartDate (your table cell content) = 12 December 2006
Days Difference:(from the above field construction) = 10

Note that bookmark names must be unique so if you have several entries, each
one must have a different bookmarkname, so you would have to change
'StartDate' to something different for each row e.g.
A_Startdate, B_StartDate etc.

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

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Roger said:
Macropod,

Thanks for getting back to me and the link to your tutorial. I
downloaded it and read it through but am stuck on how exactly to
actually do what you talk about in the document. For example the
document states the following:
"One of the limitations of Word's formula handling in tables is its
inability to evaluate text strings, including dates. To get around
this, you need to bookmark the contents of the affected cells (not
the cells themselves) and reference those bookmarks (instead of the
cells) in the formulae. The following table demonstrates how to do
this using ASK fields to create the bookmarks:"

I have no idea how to bookmark the contents of a cell and use ASK
fields to accomplish what I need to do. Could you please point me to
somewhere on how exactly I would go about doing this. Thanks so much
for your help with this.
Roger

macropod said:
Hi Roger,

Word's equivalent to Excel's NOW() function is a DATE field.
However, even with that you can't simply use something like
{={DATE}-H2}.

To see how to do this calculation and just about everything else you
might want to do with dates in Word, check out my Date Calc
'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902
In particular, look at the items titled 'Calculate the # Days
Difference Between Two Dates' and 'Date Calculations in a Table'.

Cheers

--
macropod
[MVP - Microsoft Word]


Roger Tregelles said:
Hi Folks,

I have a word document with a table that I use to track open
reports. In one of the columns I have the date the report was
issued and in another column I report the aging of the report by
manually calculating the number of days from the date the report
was issued to the current date. I would like to use a formula like
you can do so in Excel to do this automatically. I assumed I would
use a formula like this: NOW() - H2. However when I tried that I
got a syntax error. Any ideas on what I am doing wrong in
constructing this formula? Also, is there a easy way to tell what
cell you are currently working in? Any and all help will be greatly
appreciated. Roger Tregelles
Quality Assurance Engineer
Respironics Inc.
 
M

macropod

Hi Roger,

First off, copy the field with the calculations (i.e. the field after 'Days Difference:'
from the topic titled 'Calculate the # Days Difference Between Two Dates' and paste it
into the cell when you want the result to appear.

From what you originally posted, the date the report was issued is in Cell H2 in your
table. So, select that date and give in a bookmark, named 'StartDate' (use
Insert|Bookmark).

The next bit depends on whether you have a 'DATE' 'CREATEDATE' 'PRINTDATE' or 'SAVEDATE'
field in your table, showing the date you want the field to calculate up to. If you:
.. do have such a field, then select that date and give in a bookmark, named 'EndDate'
.. don't have such a field, then select the field with the calculations and press Shift-F9
to expose the coding. Now change the three instances of 'EndDate' to either (a) 'DATE'
'CREATEDATE' 'PRINTDATE' or 'SAVEDATE', according to which of these you want to use. These
are explained under 'date Field Basics' in the tutorial document.

Having done the above, select the field with the calculations and press F9 to update the
calculation.

As Graham said in his post, bookmark names must be unique. So, if you have more than one
calculation in your document, you'll need to edit the 'StartDate' bookmarks *and* the
formula field references to suit. You might use a convention like Graham suggested or you
could incorporate the cell reference into the bookmark name, using something like
''H2Date', for example.

Cheers

--
macropod
[MVP - Microsoft Word]


| Macropod,
|
| Thanks for getting back to me and the link to your tutorial. I downloaded it
| and read it through but am stuck on how exactly to actually do what you talk
| about in the document. For example the document states the following:
|
| "One of the limitations of Word's formula handling in tables is its
| inability to evaluate text strings, including dates. To get around this, you
| need to bookmark the contents of the affected cells (not the cells
| themselves) and reference those bookmarks (instead of the cells) in the
| formulae. The following table demonstrates how to do this using ASK fields
| to create the bookmarks:"
|
| I have no idea how to bookmark the contents of a cell and use ASK fields to
| accomplish what I need to do. Could you please point me to somewhere on how
| exactly I would go about doing this. Thanks so much for your help with this.
|
| Roger
|
| | > Hi Roger,
| >
| > Word's equivalent to Excel's NOW() function is a DATE field. However, even
| > with that you can't simply use something like
| > {={DATE}-H2}.
| >
| > To see how to do this calculation and just about everything else you might
| > want to do with dates in Word, check out my Date Calc
| > 'tutorial', at:
| > http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902
| > In particular, look at the items titled 'Calculate the # Days Difference
| > Between Two Dates' and 'Date Calculations in a Table'.
| >
| > Cheers
| >
| > --
| > macropod
| > [MVP - Microsoft Word]
| >
| >
| > | > | Hi Folks,
| > |
| > | I have a word document with a table that I use to track open reports. In
| > one
| > | of the columns I have the date the report was issued and in another
| > column I
| > | report the aging of the report by manually calculating the number of
| > days
| > | from the date the report was issued to the current date. I would like to
| > use
| > | a formula like you can do so in Excel to do this automatically. I
| > assumed I
| > | would use a formula like this: NOW() - H2. However when I tried that I
| > got a
| > | syntax error. Any ideas on what I am doing wrong in constructing this
| > | formula? Also, is there a easy way to tell what cell you are currently
| > | working in? Any and all help will be greatly appreciated.
| > |
| > | Roger Tregelles
| > | Quality Assurance Engineer
| > | Respironics Inc.
| > |
| > |
| >
| >
|
|
 
R

Robert M. Franz (RMF)

Hello Roger

Roger said:
I would like to use
a formula like you can do so in Excel to do this automatically. I assumed I
would use a formula like this: NOW() - H2. However when I tried that I got a
syntax error.

I have yet to find an example where it is justified to go to all the
lengths (see other answers) using Word instead of Excel for the task you
are proposing.

2cents
Robert
 
R

Roger Tregelles

Thanks for Graham and Macropod's help. I'm inclined to listen to Robert here
and just use Excel instead as this seems to be way too much work for my
purposes.

Roger Tregelles
 

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