I may not be on-target with what you want but....

If you just want to increment increase/decrease dates by 1 I would suggest doing date math.

dDateVal = dDaveVal + 1

If you have to work with a string as a source, you could convert it to date first. For example
cteststr = "2019-12-31"

ddateval = DATE(VAL(SUBSTR(cteststr,1,4)), VAL(SUBSTR(cteststr,6,2)), VAL(RIGHT(cteststr,2)))
ddateval = ddateval + 1

(the above assumes you can ALWAYS really on the format to be "YYYY-MM-DD" - with no spaces - aka Feb 5, 2019 would be 2019-02-05)

And then if you need it as a string coming out:

cNewStr = str(year(ddateval), 4) + "-" + strtran(str(month(ddateval),2), " ", "0") + "-" + strtran(str(day(ddateval),2), " ", "0")

(I put the "STRTRAN" in there to force the day result to a 2-character 0-filled value)

-Charlie

On 7/17/2016 12:28 PM, Gene Wirchenko wrote:
Hello:

I write a logic/math puzzle each week. They appear in my blog (http://genew.ca/) and two local newspapers.

     Here is the latest problem:

"Consider a date in YYYY-MM-DD format. What is the next date where all eight digits will be different?"

I solved this by hand. I decided to verify my solution with a program. I often cook up something in GW-BASIC, but since VFP has date functions, I decided to go with it.

It was very easy to set up the framework of the loop. What threw me for a loop is how to check that all of the digits are different. I ended up converting the date to string with dtos() and then testing the string with a rather ugly-looking condition. Is there something faster?

[snip]


_______________________________________________
Post Messages to: [email protected]
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/[email protected]
** 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.

Reply via email to