Date Calculation Question for Macropod

J

Jenny B.

Hi Macropod,

I’ve read through your past postings on how to calculate between dates for
different periods of time (great work by the way). However, most of the
examples don’t seem to focus on doing calculations for just Time Difference
vs. calculating Date Periods. I’m trying to add time to the SAVEDATE time
value. I still need the SAVEDATE value to appear on my form, but I’m hoping
to add another field using that same logic as a springboard. I’d like to add
12 hours to the SAVEDATE time after the user saves the doc, but show just the
hour, minute, seconds and am/pm after calculation.

Do you have any other postings or documentation that provides examples doing
this vs. calculating the date periods?

Thank you for your review and thoughts – Jenny B.


EXAMPLE -- {=SAVEDATE \@ “M/d/yyy h:mmm:ss am/pmâ€} + 12 hours - - GOAL –
to have result appear as just H:MMM:SS AM/PM 12 hours later
 
M

macropod

Hi Jenny,

This is quite simple. If, for example you were to use the first field under the heading 'Automatically Calculate A Past Or Future
Time of Day', you could modify the Time1 and Time1 parameters code from:
{SET Time1 {TIME \@ HH:mm:ss}}
{SET Time2 12:34:56}

to
{SET Time1 {SAVEDATE \@ HH:mm:ss}}
{SET Time2 12:00:00}

Note that the 'ss' part of the SAVEDATE always returns '00', so you can't really get a meaningful 'ss' calculation. If you therefore
want to force the calculation to round up to the next whole minute, you could change:
{SET Time2 12:00:00}
to
{SET Time2 12:01:00}
Be aware, though, that this will add 1 minute to the result even where the actual SAVEDATE time occurred on an exact minute
boundary.
 
G

Graham Mayor

Macropod has covered TIME delays at the end of document you can download
from http://www.gmayor.com/downloads.htm#Third_party
To add 12 hours to the Time associated with the SAVEDATE, substitute
SAVEDATE for the TIME field and change the delay to 12:00:00 thus:

{QUOTE
{SET Time1 {SAVEDATE \@ HH:mm:ss}}
{SET Time2 12:00:00}
{SET SumTime{=({Time1 \@ HH}+{Time2 \@ HH})*3600+({Time1 \@ mm}+{Time2 \@
mm})*60+{Time1 \@ ss}+{Time2 \@ ss}}}
{=INT(SumTime/86400) \# +0\ ;-0\ ;}
{=(MOD(ABS(INT(SumTime/3600)+11),12)+1)*10000+INT((SumTime-INT(SumTime/3600)*3600)/60)*100+MOD(SumTime,60)
\# 0:00:00}
{IF{=MOD(INT(SumTime/3600),24)}< 12 \ a.m. \ p.m.}}

or (24 hour clock).


{QUOTE
{SET Time1 {SAVEDATE \@ HH:mm:ss}}
{SET Time2 12:00:00}
{SET SumTime{=({Time1 \@ HH}+{Time2 \@ HH})*3600+({Time1 \@ mm}+{Time2 \@
mm})*60+{Time1 \@ ss}+{Time2 \@ ss}}}
{=INT(SumTime/86400) \# +0\ ;-0\ ;}
{=(MOD(ABS(INT(SumTime/3600)+23),24)+1)*10000+INT((SumTime-INT(SumTime/3600)*3600)/60)*100+MOD(SumTime,60)
\# 00:00:00}}

Note that savedate fields do not update automatically when you save the
document. This can result in the form showing incorrect dates and then if
the fields are updated the form will require saving again to record the new
savedate, and thus the savedate saved with the document is the previous
savedate and not the current one. Are you sure that Savedate is the best
date type for your requirements? Frankly if you save the form as a template
and create form documents from it Createdate would probably make more sense.

No doubt Macropod will be along soon with his observations

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Hi Graham,

"No doubt Macropod will be along soon with his observations". Hmm, 'soon' has interesting connotations in this context - my initial
reply preceded yours!
 
G

Graham Mayor

At the time I prepared my message you hadn't posted .. so 'soon' then
applied :)
It's all to do with the speed the system is refreshed and it does sometimes
make individual replies seem a bit odd ... or annoyingly irrelevant :(

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jenny B.

Thank you. This works just the way I was hoping and I really appreciate your
help.

Take care and thanks again – Jenny B.


macropod said:
Hi Jenny,

This is quite simple. If, for example you were to use the first field under the heading 'Automatically Calculate A Past Or Future
Time of Day', you could modify the Time1 and Time1 parameters code from:
{SET Time1 {TIME \@ HH:mm:ss}}
{SET Time2 12:34:56}

to
{SET Time1 {SAVEDATE \@ HH:mm:ss}}
{SET Time2 12:00:00}

Note that the 'ss' part of the SAVEDATE always returns '00', so you can't really get a meaningful 'ss' calculation. If you therefore
want to force the calculation to round up to the next whole minute, you could change:
{SET Time2 12:00:00}
to
{SET Time2 12:01:00}
Be aware, though, that this will add 1 minute to the result even where the actual SAVEDATE time occurred on an exact minute
boundary.

--
Cheers
macropod
[MVP - Microsoft Word]


Jenny B. said:
Hi Macropod,

I’ve read through your past postings on how to calculate between dates for
different periods of time (great work by the way). However, most of the
examples don’t seem to focus on doing calculations for just Time Difference
vs. calculating Date Periods. I’m trying to add time to the SAVEDATE time
value. I still need the SAVEDATE value to appear on my form, but I’m hoping
to add another field using that same logic as a springboard. I’d like to add
12 hours to the SAVEDATE time after the user saves the doc, but show just the
hour, minute, seconds and am/pm after calculation.

Do you have any other postings or documentation that provides examples doing
this vs. calculating the date periods?

Thank you for your review and thoughts – Jenny B.


EXAMPLE -- {=SAVEDATE \@ “M/d/yyy h:mmm:ss am/pmâ€} + 12 hours - - GOAL –
to have result appear as just H:MMM:SS AM/PM 12 hours later
 

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