Complex date comparison/Selection using fields instead of VBA
I have a bit of a nasty problem which I suspect only macropod or gmayor are going to be able to answer (first time poster, but have been lurking around reading their stuff for a few months), but I'll ask it for anyone that fancies having a go. I've been trawling for answers on this for a few months and made some progress but the final hurdle eludes me.
Due to IT restrictions, I can't use VBA for this, otherwise it'd be a doddle, so I need to do it in word fields.
I need to be able to take two dates (Date1, Date2), get a calculated date (CalcDate = Date1 +28 Days), and then display either Date2 or CalcDate, whichever is *earliest*.
I have succesfully implemented macropod's Date Calculation method to display CalcDate in another document. However, I'm having a bit of a head melt around expanding it out to a longer process (how to implement field codes isn't nearly as obvious as VBA...).
The way I think this should look is:
{QUOTE {
{Set Delay 28}
{Set Difference {= (Code from "Calculate the # Days Difference Between Two Dates" using Date1 & Date2)}
{IF {Difference} > {Delay} "{= (Code from "Calculate a day, date, month and year, using n days delay") referencing Date1}" "Date2"}
}}
Am I on the right track or am I missing something fairly obvious here?
|