In date type, we get the month, date and year. How can I set get year only?
FM has a "year" function to extract the year from a date. Since the year is just a number, if you are going to store that in a date field you will storing a date of Jan 1st of that year. So you may want to store it in its own number field.
Thanks wimdecorte for this helpful advise. Keep it up!
Yes! the Year(date) is a great function for pulling just this value out of another valid date.
Yes! you can store a Year in a date field and FileMaker thinks for you by putting month=1 and day=2. It may or may not be what you want, but it's a useful feature.
You can also format a date so that only the year is shown in the field on the layout.
personally, I like to have a separate number field (auto-enter, perhaps) that is just the year. If I have a field "my_date", then the auto-enter is "Year(my_date)". AND I like to have a yearMonth field (also auto-enter perhaps) used for sorting and grouping - it's a text field, but sorts correctly.
yearMonth=GetAsText( Year(my_date) & "_" & Right("00" & Month(my_date); 2) )
1/1/2010 => 2010_01
Beverly Voth wrote: Yes! you can store a Year in a date field and FileMaker thinks for you by putting month=1 and day=2. It may or may not be what you want, but it's a useful feature.
Beverly Voth wrote:
Hmm. My version seems to be lacking this "feature". Entering year only into a date field produces an error message: "The value of this field must be a valid date in the range of years 1 to 4000 and should look like “...”."
As Beverly indicated, you need to enter values for month and day do that it has a valid date.
Depending on the final desired result, perhaps a text or number field would be a better choice.
Bruce said, “Depending on the final desired result, perhaps a text or number field would be a better choice.”
Also, realize that the Year function referred to by Wim, returns a number type result, not a date type.
So I second Bruce’s suggestion that a number field would be a better choice.
Retrieving data ...