Date Calculation Discussions (1.00)

#1 User is offline   macropod

  • Silver Lounger (over 1600 posts)
  • Group: Moderator
  • Posts: 2379
  • Joined: 2002-05-11
  • Location:Canberra, Australian Capital Territory, Australia

Posted 2004-12-03 21:30

This thread has been created for the purpose of continuing the Date Calculation discussions started in the Star Post thread at post 249902

#2 User is offline   CurtisMinBC

  • Registered Lounger
  • Group: Member
  • Posts: 8
  • Joined: 2004-12-01
  • Location:The Okanagan, Br. Columbia, Canada

Posted 2004-12-04 09:50

Phil,

I still have not gotten it yet as I did what you suggested but now the date is showing as May 12, 2004 even though my clock on Windows is showing the correct date for today (12/4/04).

As well their were four instances of the word date so I changed each individually and even all four but that still did not fix it.

I've attached a PDF file I created showing what I have for the field data.

Thanks again...

Curtis

Attached file(s)



#3 User is offline   macropod

  • Silver Lounger (over 1600 posts)
  • Group: Moderator
  • Posts: 2379
  • Joined: 2002-05-11
  • Location:Canberra, Australian Capital Territory, Australia

Posted 2004-12-04 21:58

Hi Curtis,

The problem you're now having is because you're using a US date format, whereas the document uses non-US date formatting. This issue is discussed in the intro. To get the result you want, change:
'dd*10^6+mm'
on the last line of the field to:
'mm*10^6+dd'

Cheers

#4 User is offline   Duncan McDonald

  • Registered Lounger
  • Group: Member
  • Posts: 35
  • Joined: 2004-11-25

Posted 2004-12-06 17:40

(Edited by HansV to make provide link to post - see Help 19)

Hi Macropod

Thanks for the help with date calculation - post 431960

I am trying to format the output of the forward date calculated in Post 431960 in the form e.g. 31st June 2005 but with the 'st' in superscript. I can't see how I can combine the code in that section of your download with the code created to generate the date and generate the printed output.

Please can you help

Best regards

#5 User is offline   macropod

  • Silver Lounger (over 1600 posts)
  • Group: Moderator
  • Posts: 2379
  • Joined: 2002-05-11
  • Location:Canberra, Australian Capital Territory, Australia

Posted 2004-12-06 21:22

Hi Duncan,

Change the last line from:
{=mm*10^6+dd*10^4+yy # "00'-'00'-'0000"} @ "dddd, MMMM d yyyy"}
(I'm guessing that you're using a 'dddd, MMMM d yyyy' output format) to:
{=mm*10^6+dd*10^4+yy # "00'-'00'-'0000"} @ "dddd, MMMM d

#6 User is offline   Duncan McDonald

  • Registered Lounger
  • Group: Member
  • Posts: 35
  • Joined: 2004-11-25

Posted 2004-12-08 10:35

Hi Macropod

Thank you again - Contrary to how it may seem, I am actually doing other bits under my own steam thanks to your help.

Best regards

#7 User is offline   Duncan McDonald

  • Registered Lounger
  • Group: Member
  • Posts: 35
  • Joined: 2004-11-25

Posted 2004-12-09 14:50

Hi Macropod

I've been testing the date calculations at extremes again before releasing the document and there seems to be a further problem with February.
If 6 months is added to Aug 29th the answer is 29-02-2005. Word formating recognises the problem and it does not display properly. The same is true for other years except leap years - when Feb 29th does exist. It is not August specific and 28th Feb is displayed correctly when the 30th and 31st of the month are entered. Also on leap year if 31st of Aug 04 has 42 months added the date reverts to 29th Feb 08 which is correct.
Have you any suggestions?

Thanks and regards
Duncan

#8 User is offline   macropod

  • Silver Lounger (over 1600 posts)
  • Group: Moderator
  • Posts: 2379
  • Joined: 2002-05-11
  • Location:Canberra, Australian Capital Territory, Australia

Posted 2004-12-09 22:24

Hi Duncan,

Sorry 'bout that. The '>29' in the 'SET dd' expression should have been '>28' stupidme.

Cheers

#9 User is offline   Duncan McDonald

  • Registered Lounger
  • Group: Member
  • Posts: 35
  • Joined: 2004-11-25

Posted 2004-12-14 18:15

Hi Macropod

Have now done wonders in docs thanks to your date help

Am not sure if the attachment is of any use to anyone or if I reinvented a wheel.

The * Cadtext switch does not properly create a printed output for money as an example. I crated the attachment that seems to work and wondered if it might be of use to others and if perhaps you wanted to check it and let others see it?

Regards

Duncan

Attached file(s)



#10 User is offline   Charles Kenyon

  • 5-Star Lounger (over 600 posts)
  • Group: Member
  • Posts: 1154
  • Joined: 2001-01-26
  • Location:Madison, Wisconsin, Wisconsin, USA

Posted 2004-12-14 19:15

Hi,

First, I think you mean * Cardtext.

Second, have you tried * DollarText?

#11 User is offline   macropod

  • Silver Lounger (over 1600 posts)
  • Group: Moderator
  • Posts: 2379
  • Joined: 2002-05-11
  • Location:Canberra, Australian Capital Territory, Australia

Posted 2004-12-15 04:29

Hi Duncan,

Your field can be both simplified and extended, as per second example in the attached in which I've implemented a solution using a FILLIN field that you could easily replace with your mergefield. This will deal with pounds to 9 digits and pennies, both as positive and negative values.

For more on Word field maths and numeric picture switches, see post 365442.

Cheers

Attached file(s)



#12 User is offline   macropod

  • Silver Lounger (over 1600 posts)
  • Group: Moderator
  • Posts: 2379
  • Joined: 2002-05-11
  • Location:Canberra, Australian Capital Territory, Australia

Posted 2005-03-22 08:23

Hi Duncan,

The code in the Date Calc document (see post 249902) has now been updated, with a new and simpler algorithm for applying the 'February' test. The relevant code portion is now:
{SET dd{=IF(({DATE @ d}>28)*(mm=2)=1,28+((MOD(yy,4)=0)+(MOD(yy,400)=0)-(MOD(yy,100)=0)),IF((mm=4)+(mm=6)+(mm=9)+(mm=11)+({DATE @ d}>30)>1,30,{DATE @ d}))}}

Cheers

#13 User is offline   gogetter

  • Registered Lounger
  • Group: Member
  • Posts: 9
  • Joined: 2005-04-24

Posted 2005-04-24 12:25

I'm looking to calculation the last day of the previsous month with a "MMMM d yyyy" format. Please help.

#14 User is offline   macropod

  • Silver Lounger (over 1600 posts)
  • Group: Moderator
  • Posts: 2379
  • Joined: 2002-05-11
  • Location:Canberra, Australian Capital Territory, Australia

Posted 2005-04-25 21:37

(Edited by macropod on 26-Apr-05 08:37. Corrected INT syntax error in SET yy field.)

Hi gogetter,

You can do this by modifying the field found under 'Calculate the day & date of the last or nth-to-last day of this month' in the DateCalc document (post 249902). The steps are as follows:
. After the embedded field '{SET Subtract 0}', insert a new field coded as '{SET MAdjust -1}'
. Change the '{SET yy{DATE @ yyyy}}' field to '{SET yy{={DATE @ yyyy}+INT(({DATE @ M}+MAdjust)/12)}}'
. Change the '{SET mm{DATE @ M}}' field to {SET mm{=MOD({DATE @ M}+MAdjust-1,12)+1}}
. Change the 'dd*10^6+mm*10^4+yy' string to 'mm*10^6+dd*10^4+yy'
. Change the '"dddd, d

#15 User is offline   gogetter

  • Registered Lounger
  • Group: Member
  • Posts: 9
  • Joined: 2005-04-24

Posted 2005-04-25 18:08

Hi Macropod -- Thanks for the quick reply. Here's what I have and it still comes up as dddd, d MMMM yyyy. Please help. Looking for MMMM dd yyyy. Thanks a bunch.

Attached file(s)



#16 User is offline   macropod

  • Silver Lounger (over 1600 posts)
  • Group: Moderator
  • Posts: 2379
  • Joined: 2002-05-11
  • Location:Canberra, Australian Capital Territory, Australia

Posted 2005-04-25 21:49

Hi gogetter,

I think the reason the output hadn't changed was that you hadn't updated the field, which you do by pressing F9 - it looks like you'd simply toggled the coding view off via Shift-F9 or Alt-F9.

Had the field updated, it would have disappeared from view because of a number of editing errors. For example, you used standard braces instead of field braces (created via Ctrl-F9) in a number of places and the SET yy field has the INT expression on the wrong side of a set of field braces. You also deleted the '=' sign on the last line and replaced it with a pair of single quotes around the 'mm*10^6+dd*10^4+yy' expression. As with most programming languages, Word's field coding has an unforgiving set of syntax requirements, without which things fall over.

I've added a correctly-coded version of the field to your document so that you can compare the two (and use the latter).

Cheers

Attached file(s)



#17 User is offline   gogetter

  • Registered Lounger
  • Group: Member
  • Posts: 9
  • Joined: 2005-04-24

Posted 2005-04-26 00:13

Macropod - This is AWESOME! Thank you so much. Also, thanks for the explanation, it really helped!

#18 User is offline   hec79red

  • Registered Lounger
  • Group: Member
  • Posts: 3
  • Joined: 2005-07-26

Posted 2005-07-26 09:18

Hi Macropod
I want to create a field in a work document that takes the current days date and adds 19 days to it. I have read your file and just confused myself!
Hope you can help!

#19 User is offline   Slinky

  • Slinky
  • Group: Member
  • Posts: 84365
  • Joined: 2002-03-22

Posted 2005-07-26 09:56

Welcome to Woody's Lounge.

In macropod's document, look for the section labeled "Calculate a day, date, month and year, using n (301) days delay" (it's at the end of page 6 on my PC, but pagination might be slightly different on yours). This section contains a field that at the moment displays Tuesday, 17 January 2006 if you haven't updated the field, or Tuesday, 23 May 2006 (i.e. 301 days after today, 26 July 2005) if you have. Select this field, then right-click it and select Toggle Field Codes from the popup menu. You'll see

{QUOTE
{SET DELAY 301}
{SET ...

Change the 301 to 19, taking care not to change anything else. Then press F9 to hide the field codes and update the result, You should see Sunday, 14 August 2005.

You can copy the field to the clipboard and paste it into your own document.

#20 User is offline   hec79red

  • Registered Lounger
  • Group: Member
  • Posts: 3
  • Joined: 2005-07-26

Posted 2005-07-26 10:14

Hi Hans
I think it has worked I just have to wait until tomorrow to see if it updates automatically on opening as I am on a networked pc and I can't change the date and time!
H



1 reading this thread
0 members, 1 guests, 0 anonymous