Re: Fun with date calculations in VFP

Author: Ted Roche

Posted: 2018-05-08 at 10:11:38

Or, cleaned up a bit:

FUNCTION olddate(thedate, offset)

* parameters: thedate: date to start from

* offset: number of years offset, positive or negative

* returns: nearest date to the offset that falls on the same day of the week

LOCAL thediff, theoffset

thediff = DOW(thedate)-DOW(gomonth(thedate, offset*12))

theoffset = IIF(thediff>3, 7-thediff, thediff)

RETURN GOMONTH(thedate, offset*12) + theoffset

--

Ted Roche

Ted Roche & Associates, LLC

http://www.tedroche.com

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CACW6n4tCYNwN2uJC0i+=jm2GSB57G1vyY=MZQ2Fvp6+ZkTHDEw@mail.gmail.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2018 Ted Roche