A date is really a number field that stores the number of days since 12/31/0000 with special built in formatting to display that number as a date. If you do not specify a month and day, Filemaker is unable to convert your input into this number. If you leave out the year, it will assume the current year, but there's no way for it to "guess" what value you want to enter for a missing month or year.
To enter what you describe, you'd have to use either a field of type text or use the OnObjectValidate (new with FileMaker 11) trigger to intercept this error and to reformat data with such missing info with default values that you specify in the script (such as a 1 for missing month and day information).
Could you please give me an example of how to use the OnObjectValidate trigger in this scenario?
Unlike just entering a date, the details will now depend on the delimitters you choose to use when entering dates as the script will have to process the input data to parse out the values entered in order to provide default values for anything that is missing.
We'll assume you use / as your date delimitter, but this script can be modified to use other delimitters or even combinations of them if needed:
Set Variable [ $DateText; Value:GetAsText ( YourTable::YourDateField ) ]
Set Variable [ $DelimCount; Value:PatternCount ( $DateText ; "/" ) + 0 ]
If [ $DelimCount = 0 // year only entered ]
Set Field [ YourTable::YourDateField ; Date ( 1 ; 1 ; $DateText ) ]
Else If [ $DelimCount = 1 // month/year entered ]
Set Field [ YourTable::YourDateField ;
Let ( [ d = Position ( $DateText ; "/" ; 1 ; 1 ) ; L = Length ( $DateText ) ] ; Date ( Left ( $DateText ; d - 1 ) ; 1 ; Right ( $DateText ; L - d ) ) ) ]
So what you're saying is that there really isn't any way to input a year or month/year by itself and that the script above places a "1" wherever a value is missing from the month/day/year date format...
That's what I said from the beginning. FileMaker stores dates as a number that requires a day, month and year in order to produce that number. It can provide the current year as the default year if you only enter month and day, but not either of the other two values.
You can use a text field instead.
You can format the date field to only display only the year or only display the month and year if that is all that is required for your layout.
Are there any drawbacks to using a text field instead of a date field to note the date?
Yes there are. Dates can be correctly sorted in ascending or descending order. They can be formatted with data formatting settings available for dates. You can use them in calculations just as though they are the number fields they really are as long as you understand that the numbers are counting days.
Text fields will sort according to the rules for text fields so sorting the field in ascending order will not put 12/2011 after 4/2011 as expected and cannot be used the same way in calculations.
Much depends on how you intend to use this data.
Note: It's possible to set up a date field with an auto-entered calculation where you can select any date in the calendar pop-up, but the calculation converted it to the date for the 1st of the same month and displayed the data in Month/Year format...