In Visual Basic and MS Access, I am able to use the DateAdd function to add one year to a date. What is the equivalent function in Visual FoxPro? Does somebody have an example?
Actually, FoxPro is even easier than either of those when it comes to adding dates. However, adding an exact year would be a little more complex. Here's the basics:
To go forward or backward a number of days, simply add the number. Example:
Code:
ldToday = DATE()
ldTomorrow = ldToday+1
Pretty easy, huh? That will simply go forward or backward a single day, wrapping to the next/previous month and year if necessary. To add a month or a year, though, gets a little bit more complex...you'll need to split the date into the 3 fields. So, to add a year, do this:
Not really simple, but the above code should allow you to take a date field and add a year to it. Be sure to change the order of the lcNewdate assignment if your regional settings for date format aren't DD/MM/YYYY.
Well, I'm using Visual Basic and SQL Server to achieve these results, as the program I am trying to change uses FoxPro as their back-end, but only through .DBF files. There is a completely separate front-end. Is there any way to do this via Visual Basic?
IF.... myDate = DATE() .........
myDatePlus1Month = GOMONTH(myDate,1)
myDateMinus1Month = GOMONTH(myDate,-1)
myDate1stDate = myDate - DAY(myDate) + 1
myDateLastDate = GOMONTH(myDate,1) - DAY(myDate)
.... so on
Hope this helps you
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.