I'm working in FM 11. I have a date field and need to know how to add 35 years to it. Example: 2/8/1988 + 35 years. Can you help me?
Date ( month ( datefield ) ; day ( datefield ) ; year ( datefield) + 35 )
Although I realize Phil was just giving you a quick answer to show how simple things can be, I still wouldn't hard-code the date number like this. You never know when 35 might need to be another number -- requiring you to possibly make a code change. It's better to avoid magic numbers (hard-coded constants) and instead get this value from a field. Then, if the value needs to change, you change the field (data) not code.
Magic number (programming) - Wikipedia
valid point, fmpdude!
This is where a custom function can be valuable because such value(s) can be passed as parameters to a function:
You see from the help topic, that FMPro Advanced is needed to create (and install) these, but they can be used again and again in FMPro.
If you don't have FMPA, scripting can often accomplish the same thing.
fn_inc_years(dt;inc) =Let ([ m = Month(dt); d = Day(dt); y = Year(dt); result = Date ( m ; d ; y + inc )]; result) // pass the values of date (dt) and increment (inc) to this function
[ m = Month(dt)
; d = Day(dt)
; y = Year(dt)
; result = Date ( m ; d ; y + inc )
) // pass the values of date (dt) and increment (inc) to this function
Retrieving data ...