Another guy that fixes his typos the 2nd time... 😊 Thanks, Ted!
--
rk
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Ted Roche Sent: Tuesday, May 08, 2018 11:12 AM To: profoxtech@leafe.com Subject: Re: Fun with date calculations in VFP
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