Okay, so this worked. Much cleaner but can't get the leading zeros on days and months
Substitute (Get(CurrentDate) - Day (1) ; "/" ; "-" )
I want to set up a button to insert yesterdays date into a field. The kicker is that it has to be entered into the field with hyphens, not the filemaker "/". It's used in a URL and needs to be formatted as MM-DD-YYY.
Why put this value into any field? You can query that value and put it into the desired format while constructing that URL.
A correct way to get that format would be:
Let ( [
theDate = Get ( CurrentDate ) - 1 ; // base unit for dates is one (1) day
m = Right ( "00" & Month ( theDate ) ; 2 ) ;
d = Right ( "00" & Day ( theDate ) ; 2 )
m & "-" & d & "-" & Year ( theDate )