RE: Fun with date calculations in VFP

2018-05-08 Thread Richard Kaye
Or an ICASE? (I haven't quite wrapped my head around what you're doing there but it seems like there are 3 states?) m.theOffset=ICASE(theDiff>3, 7-m.theDiff,theDiff<-3, 7+m.theDiff, m.theDiff) -- rk -Original Message- From: ProfoxTech On Behalf Of Ted

Re: Fun with date calculations in VFP

2018-05-08 Thread Ted Roche
GOMONTH() just moves back to 2/28 on years that don't have a 2/29, so your olddate({^2016-02-29},-2) gives you the previous Tuesday, 2/24/2014. Hmmm. That's an OBO. It goes back 4 instead of forward 3. I think the nearest date ought to be 2014-03-03 Ah, if thediff = -4, it remains -4. That's a

RE: Fun with date calculations in VFP

2018-05-08 Thread Richard Kaye
I owe you a Scotch next time you're in the area. -- rk -Original Message- From: ProfoxTech On Behalf Of Ted Roche Sent: Tuesday, May 08, 2018 5:15 PM To: profoxt...@leafe.com Subject: Re: Fun with date calculations in VFP Did I mention I like date math?

Re: Fun with date calculations in VFP

2018-05-08 Thread Ted Roche
An ICASE might do it. Basically the idea is get the day number (DOW) of the current date, like 2 for Tuesday if SET FDOW is 1 ("the first day of the week is Monday") Then create a new date with GOMONTH() and get the day number of that, some number 1 through 7. So if the new date is a five, I

Re: Fun with date calculations in VFP

2018-05-08 Thread Ted Roche
How about: FUNCTION olddate(thedate, offset) * parameters: * the date: the source date * offset number of years offset, positive or negative * returns: the nearest date that is the same day of week as the source date LOCAL thediff, theoffset thediff = DOW(thedate) - DOW(GOMONTH(thedate,

Re: Fun with date calculations in VFP

2018-05-08 Thread Ted Roche
Did I mention I like date math? Brain-twisting stuff. On Tue, May 8, 2018 at 5:14 PM, Ted Roche wrote: > How about: > > FUNCTION olddate(thedate, offset) > * parameters: > * the date: the source date > * offset number of years offset, positive or negative > * returns: the

Re: [NF] No Internet Connect

2018-05-08 Thread Charles Hart Enzer, M.D.
Thank you, Chang. Now, still 1709 My Restore Points only go back to 5/4 when the problem of connecting began. Don't know how to get earlier Restore Points. *Shai / שי Charles Hart Enzer, M.D., FAACAP* *Aliyah : Cincinnati to Jerusalem

Fun with date calculations in VFP

2018-05-08 Thread Richard Kaye
While doing my due diligence on the subject I thought I’d toss it out here in case someone already has a function handy that will do this, thus saving me the effort of thinking too hard too early in the day.  Here’s the goal. I want to take a date, say today, Tuesday May 8, 2018 and figure

Re: [NF] No Internet Connect

2018-05-08 Thread Man-wai Chang
Is your desktop also using wifi connection? Weird that only the laptop and cell phone could talk to the wireless router. If your desktop used wired LAN, set a static IP and see if it could ping the router. Since you are still in 1709, it's not the recent 1803 upgrade. On Mon, May 7, 2018 at

RE: Fun with date calculations in VFP

2018-05-08 Thread Dave Crozier
clear set century on dDate=Date() ? DateAdd("YY", 5, dDate) ? DateAdd("WEEK", 5, dDate) * return * Mirrors TSQL DateAdd() Function * Example: * ? DateAdd("YY", 2, Date()) * Function DateAdd(tcInterval,tnIncrement,tdDateTime) Local strTime As String,strOldExact As String,strOldDate As

Re: Fun with date calculations in VFP

2018-05-08 Thread Ted Roche
So, do you want a function that returns the second Tuesday in May or one that returns the Tuesday closest to May 8? Both would fit the specs. Date math was one of my many VFP hobbies. There were lots of date math answers in Ask Advisor. GOMONTH() gets you to the year you want, then you can use

RE: Fun with date calculations in VFP

2018-05-08 Thread Richard Kaye
The latter. And that was the approach I was just working through. Thanks to both you and Dave for chiming in. -- rk -Original Message- From: ProfoxTech On Behalf Of Ted Roche Sent: Tuesday, May 08, 2018 9:15 AM To: profoxt...@leafe.com Subject: Re: Fun

RE: Fun with date calculations in VFP

2018-05-08 Thread Dave Crozier
Richard, It was the Google Effect ... just like mine!! Dave Crozier Software Development Manager Flexipol Packaging Ltd. --- This communication and the information it contains is intended for the person or organisation to whom it is

RE: Fun with date calculations in VFP

2018-05-08 Thread Richard Kaye
Another guy that fixes his typos the 2nd time...  Thanks, Ted! -- rk -Original Message- From: ProfoxTech On Behalf Of Ted Roche Sent: Tuesday, May 08, 2018 11:12 AM To: profoxt...@leafe.com Subject: Re: Fun with date calculations in VFP Or, cleaned up a

Re: Fun with date calculations in VFP

2018-05-08 Thread Ted Roche
On Tue, May 8, 2018 at 11:23 AM, Richard Kaye wrote: > Another guy that fixes his typos the 2nd time...  Thanks, Ted! :) Well, the first version ran great in GMail! The second version I actually tried running in VFP ;) ___ Post

RE: Fun with date calculations in VFP

2018-05-08 Thread Richard Kaye
lol -- rk -Original Message- From: ProfoxTech On Behalf Of Ted Roche Sent: Tuesday, May 08, 2018 11:28 AM To: profoxt...@leafe.com Subject: Re: Fun with date calculations in VFP On Tue, May 8, 2018 at 11:23 AM, Richard Kaye wrote: >

RE: Fun with date calculations in VFP

2018-05-08 Thread Richard Kaye
I was just looking at your code and noticed the bit at the end seemed to have something missing.  SET DATE BRITISH? What's that? -- rk -Original Message- From: ProfoxTech On Behalf Of Dave Crozier Sent: Tuesday, May 08, 2018 9:29 AM To:

Re: Fun with date calculations in VFP

2018-05-08 Thread Ted Roche
On Tue, May 8, 2018 at 9:14 AM, Ted Roche wrote: > So, do you want a function that returns the second Tuesday in May or > one that returns the Tuesday closest to May 8? Both would fit the > specs. > > Date math was one of my many VFP hobbies. There were lots of date math >

Re: Fun with date calculations in VFP

2018-05-08 Thread Ted Roche
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 =

RE: Fun with date calculations in VFP

2018-05-08 Thread Dave Crozier
Error Fix: The function should read as follows: *** * Mirrors the SQL DateAdd() function * Written By: R.D.Crozier * From an idea in MSDN Forum * Function DateAdd(tcInterval,tnIncrement,tdDateTime) Local strTime As String,strOldExact As String,strOldDate As String,vReturn

Re: Fun with date calculations in VFP

2018-05-08 Thread Stephen Russell
I found a millisecond approach a while back that hasn't given us any issues yet 60480 milliseconds in a week is the fact I base the code on. var date:Date = new Date(, MM, DD); Datetime lastyear = date.setMilliseconds(date.milliseconds - 60480 * 52); On Tue, May 8, 2018 at 8:07

RE: Fun with date calculations in VFP

2018-05-08 Thread Richard Kaye
The Google knows all, sees all, and has nothing but our best interests at heart. But the Google has no proofreading skills... Or DWIMNWIT  -- rk -Original Message- From: ProfoxTech On Behalf Of Dave Crozier Sent: Tuesday, May 08, 2018 12:00 PM To:

RE: Fun with date calculations in VFP

2018-05-08 Thread Gene Wirchenko
At 06:27 2018-05-08, Richard Kaye wrote: The latter. And that was the approach I was just working through. What about the week every few years that you will be disregarding? A year has 52 weeks plus one or two days. [snip] Sincerely, Gene Wirchenko

Re: Fun with date calculations in VFP

2018-05-08 Thread Jean Laeremans
Rofl Op di 8 mei 2018 16:27 schreef Ted Roche : > On Tue, May 8, 2018 at 11:23 AM, Richard Kaye > wrote: > > Another guy that fixes his typos the 2nd time...  Thanks, Ted! > > :) > > Well, the first version ran great in GMail! The second version I >

RE: Fun with date calculations in VFP

2018-05-08 Thread Richard Kaye
Ted's solution works just fine. What I didn't test yet is using leap day itself as the starting point. Hmmm. ** * Program: datestuff3.prg * Date: 05/08/2018 11:09 AM * VFP Version: Visual FoxPro 09.00..7423 for Windows *Notes: