Date calculation discussions ctd. (2.46 and later)
#1
Posted 2006-08-27 19:28
#2
Posted 2006-09-16 05:30
I did end up rearranging some lines, so the first few now read in this form:
{SET Month #}
{SET Week #}
{SET Weekday #}
{SET Year {={DATE @ yyyy}+#}}
{SET b{=(Year}+4800-a}}
... rest of calculation, format, etc.
I like this because it's then easy to check the date information right at the start, and I can specify the year I need the date for.
Most months are duly producing the first Saturday just as desired. HOWEVER, for some reason I can't work out, the December formula provides first Saturday in December for the previous year. I don't see any obvious reason why it should. File attached with a table of This Year, Next Year, Two Years from now, to illustrate the difficulty.
Weird query: I managed to tweak the code to identify Kentucky Derby Saturday (first Saturday in May) and Preakness Saturday (third Saturday in May). However, the Belmont is run 21 days after the Preakness, a Saturday which falls between June 2 and June 8 -- as you see, it is usually, but not always, the first Saturday in June. My efforts to add 21 days to the third Saturday in May caused a problem -- no doubt with the Limit code line -- and the date currently reads 40 May 2006. This is probably correct, so to speak, but a date given as "June" something would be preferable! Would it be preferable approach to attempt to add 21 days to the third Saturday in May, or would it be easier to specify "Saturday" with limits set to >June 1 and <June 9??
Many thanks,
axsc
(no hurry -- leaving town for a week in the morning)
Attached file(s)
-
MeetingSchedule.doc (94.5K)
Number of downloads: 11
#3
Posted 2006-09-28 09:35
His brilliant field codes are excellent for occasional date calculations, but Word is not the most appropriate application for large numbers of calculations, It would be much easier to accomplish what you want in Excel, since it is geared towards working with calculations and formulas, and since it has a large number of date functions built in.
#4
Posted 2006-10-03 05:58
Am still wondering why a December calculation will produce a date a year off, though.
Hope Macropod has had a splendid vacation and returns from it -- eventually -- very fit and raring to go.
axsc
#5
Posted 2006-10-30 02:11
Attached is a revised copy of your meeting schedules document.
To calculate the Belmont event date as 21 days offset from the Preakness date, I first changed the 'dd', 'mm' and 'yy' bookmark names in the Belmont field to 'pdd', 'pmm' and 'pyy', respectively. Then I modified the formula found under 'Calculate a day, date, month and year, using n (301) days delay' in my tutorial document to refer to those bookmarks instead of the system date and changed the 'Delay' value from 301 to 21.
As for the December anomaly, I fixed it by changing the expression 'MOD(Month,12)' to 'MOD(Month-1,12)+1' throughout. Thanks for finding this. Looks like I'll have to update the tutorial!
Attached file(s)
-
MeetingSchedule.doc (94K)
Number of downloads: 23
#6
Posted 2006-11-06 01:54
Many thanks for the calculations!
axsc
#7
Posted 2006-12-01 19:31
Thanks.
#8
Posted 2006-12-01 20:11
#9
Posted 2006-12-01 20:36
Could you post a copy of the document with the date and with your attempt at the calculated field? You can remove everything else from the copy.
#10
Posted 2007-01-23 22:24
At the "Automatically Insert a Past or Future Date" section, any that calculate a date using n months delay seem to trip at the change of a year. For example, it is now January. If I want to set the delay to -1 (go back one month) it still returns January. Some of the others trip up completely. I didn't see this problem addressed yet in the previous threads, if I have missed it, can someone please point me to the discussion?
Thanks
#11
Posted 2007-01-24 09:07
Apparently, the formulas don't handle negative delays correctly.
Select the entire field and press Shift+F9 to display field codes.
Part of the field code will look like
{=MOD({DATE @ M}+Delay-1,12)+1}
Change the -1 after the word Delay to +1199
{=MOD({DATE @ M}+Delay+1199,12)+1}
This effectively adds 1200 months to the delay; this is sufficient to handle negative delays up to -1200 months.
Press F9 to hide the field codes and update the field.
#12
Posted 2007-01-25 05:03
I'll be posting an update ASAP. In the meantime, you can use:
{SET mm{=MOD(ABS({DATE @ M}+Delay+11),12)+1}}
#13
Posted 2007-01-25 21:15
update: I've narrowed the problem down to the fact that while Excel says the INT(-.08333) is -1, Word persists in telling me it is 0. Anybody know a workaround for Word's abuse of mathematical conventions?
#14
Posted 2007-01-26 15:21
#15
Posted 2007-01-25 22:56
That too has been fixed, via:
{SET yy{=INT({DATE @ yyyy}+(Delay+{DATE @ M}-1)/12)}}
You can now download the update Date Calc 'tutorial' in
#17
Posted 2007-02-22 18:41
I wanted to add that it looks like a lot of work went into this document and I really think it is great resource.
Bill
#18
Posted 2007-02-22 19:02
Bill
#19
Posted 2007-02-22 20:04
Bill
#20
Posted 2007-02-22 20:46
The section named "Date input/output formats" under "Introductory Notes" near the beginning of Macropod's document mentions this issue explicitly:
Many date fields in this document are region-dependent and are coded to work on systems using day-month-year regional settings. For system using month-day-year regional settings, obtaining a correctly result is as simple as changing the order of the embedded fields coded as


This thread is closed
MultiQuote