How do I add a default date to a date field?
Can someone in this community advice on how to add default date to field? For example, the field is a Date field called Month End Date. By default, this field should show 31/03/2019. This would apply to any new record and updated records.
What is the best way to make this happen?
-
Official comment
Hi Mercedes,
The way to set this as the default value would be to use the 'Default Value' property along with 'Process Value as Default Expression' This will set the value on creation (first save) of the Record
The expression I would advise is to take Created Date and then set the value to be the first day of the next month minus one day:
addDays(string(year(addMonths(createdDate(),1))) + '-' + if(month(addMonths(createdDate(), 1)) < 10, '0', '') + month(addMonths(createdDate(),1)) + '-01T00:00:00Z',-1)
If this is also needs to run on Record Update then it will be necessary to move the Expression into the Expression property for the Field.
Comment actions
Please sign in to leave a comment.
Comments
1 comment