# alterDate ( entryDate ; m ; d ; y )

Can be used to change any or all of the month, day and/or year by adding/subtracting simple values, calculations, number/calc fields, or by substitution.

 John Knight dB SPL http://www.filemaker.com

Sample input:
alterDate ( "8/9/2010" ; 1 ; Quote(0) ; 10 )
Sample output:
8/31/2020

Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Adds the values in 'm', 'd' & 'y' to the month, day and year of 'entryDate'.
entryDate can be anything that produces a valid date (e.g. a Date field, the Date() function, Get(CurrentDate), or a date entered as text).
m, d & y can be anything that produces a number (e.g. a Number field, a number, any calculation that produces a number).
m, d & y can also be wrapped by Quote(). Doing so replaces the respective value from entryDate with that number (e.g. alterDate ( "8/9/2010" ; 1 ; Quote(0) ; 0 ) produces 9/0/2010, which evaluates to 8/31/2010.
m, d & y can be positive or negative.

Examples: (assume DateField and Get(CurrentDate) = 8/9/2010)
alterDate ( DateField ; 0 ; Quote(1) ; 0 ) = 8/1/2010 (The first of the month)
alterDate ( DateField ; 0 ; 60 ; 0 ) = 10/8/2010 (60 days out)
alterDate ( Get ( CurrentDate ) ; 0 ; -DayOfWeek ( Get ( CurrentDate ) ) ; 0 ) = ( 8 ; 9-2 ; 2010 ) = 8/7/10 (The Saturday before)
alterDate ( DateField ; GetValue ( List ( 3 ; 6 ; 9 ; 12 ) ; 3 ) ; Mod ( 12 ; 7 ) ; Quote(1999) ) = ( 8+9 ; 9+5 ; 1999 ) = 17/14/1999 = 5/14/2000
alterDate ( DateField ; 2*3 ; 4^2 ; -12 ) = ( 8+6 ; 9+16 ; 2010-12 ) = 14/25/1998 = 2/25/1999