Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
Joanna Kirk

# How do I create a field for 'year' (with a validation rule that it cannot be in the future)?

I've been told to start with a number field (4 digit limit) but need a hint on where to start with the sytax! Any help appreciated.
Best Answer chosen by Joanna Kirk
Shyama B S
So, you want to add a length check also right? You can do that like this:
```IF(Value(Year__c) > Year(TODAY()),true,IF(LEN(Year__c)=4,false,true))
```

Joanna Kirk
*syntax
Shyama B S
Hi Joanna,
You can create avalidation rule with the below formula,
`IF(Year__c > Year(TODAY()),true,false)`

Where Year__c is a custom field of number type and is chakced against the year of today. Please let me know if this helped you.
Thanks,
Shyama
Joanna Kirk
Hi Shyama, thank you - Much apppreciated!

The number displays with a comma, e.g. '2,015' - Is there any way to show this differently?
If not, should I change the data type to something else?

Shyama B S
Yes. You can change it to a text field. And update the formula like the below:
`IF(Value(Year__c) > Year(TODAY()),true,false)`

Thanks
Shyama B S
Joanna Kirk
That looks good! One last thing, the field itself is not mandatory, but I need to make sure if the users enter the year, it is done properly:

so all 4 digits, say, starting from 1300 to Year(TODAY ())  .

I'm not sure if I'm going in the right direction, but think I need to include some of the followng elements somehow: AND IF (Value(Year__c) == 4, true, false)
Shyama B S
So, you want to add a length check also right? You can do that like this:
```IF(Value(Year__c) > Year(TODAY()),true,IF(LEN(Year__c)=4,false,true))
```
This was selected as the best answer
Joanna Kirk
Great, that works well. Flagged as best answer.
Thanks and have a great day Shyama.
Shyama B S