If I were you, I'd replace that text field with a field of type date. It will make for more consistent data entry. There's a real possibility here in your text data, that one or more records will have invalid data. You can use a date field even if the year is not significant. Once you have a date field much simpler calculations can compute the date that is "5 days prior".
Let ( [ td = YourTable::YourTextField ;
p = Position ( td ; "/" ; 1 ; 1 ) ;
m = Left ( td ; p - 1 );
d = GetAsNumber ( middle ( td ; p + 1 ; 2 ) )
If ( p ; Date ( m ; d ; year ( Get ( CurrentDate ) ) ) - 5 ; "error" )
Specify date as the result type. If there is no / in the text field, a question mark will be returned.
but data entry errors can be an issue here. 2/30, for example, will produce a result of: 2/25/2013
Perfect, as always Phil...thank you so much. And I would actually much prefer to use a date field as my original entry field, but when I did that filemaker was forcing my users to enter a year which caused problems for me when they didn't know what it was. Is there a way to change this to allow entry of months and days only in a single date field?
If you are using FIleMaker 11 or newer, you can use the OnObjectValidate script trigger to supply the missing year before FileMaker's data validation rejects the input as an invalid date.
That much I could do, the unfortunate part is that in many cases I actually don't know what the year should be. This is capturing birthday and anniversary dates and often clients do not wish to reveal the actual year, only the month and day. I have to account for this in our system, but still be able to utilize these dates for searches and reports regardless of whether or not a year has been given. As far as I have found there isn't a way to use a Date field without giving it a year to work with and supplying erroneous data.
It seem that the year doesn't matter. That only the month and day are significant. In which case you can enter any year you want--the current year or just a constant value. You then have a valid date entered in the date field, but you can format the display of this date to only show the month and day.