KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using the Add to date command
PRODUCT: 4D | VERSION: 6.5 | PLATFORM: Mac & Win
Published On: July 27, 2001

The command Add to date is really useful and should be used if you need to compute dates.

Previously, you needed to add a number of days to an existing date in order to compute a date. If you needed to add months or years, you had to convert first into days and then add this number of days to your current date.

Ex: MyDate:=Current date + 60 ` For 2 months

However, the Add to date command is quite different from simply adding a number of days to an existing date. If you wanted to add one month to a date, you could try:

MyDate:=MyDate+30 ` If you believe that 30 days worth one month

or perhaps:

MyDate:=MyDate+31 ` If you believe that 31 days worth one month


But it is more simple and accurate by using Add to date:

MyDate:=Add to date(MyDate;0;1;0) ` I just asked to add one month exactly


If MyDate contains 01/31/2000, the first assignment will return 03/01/2000 and the second one will return 03/02/2000. In both cases, the date is no longer an end of the month date. However, the third case will return 02/29/2000 which is the last day of that month (2000 was a leap year).


http://www.4d.com/acidoc/cmu/CMU00393.HTM