function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Timesync0Timesync0 

Day of the month calculation

I need to have a field auto-populated by either calculation of workflow that will compare a date that is manually entered and return a date that is one month later.

Example: 3/13/2008 manually entered (Equals 2nd Thursday in March, 2008)
Auto Return: 4/10/2008 (equals 2nd Thursday in April, 2008)

I am not sure what the syntax is to Add One Month.

Can anyone help?

David
(619)719-7389
david@sandiegocrm.net
JakesterJakester
This isn't tested, but as far as how to generally add a month to a date, this is pretty straightforward. The general idea is Date(year,month,day), so you'd do something like


Code:
date(year(field_name__c),month(field_name__c)+1,day(field_name__c)

 


cdiscdis

How does this formula handle adding a month to a December date?

I am trying to do something similar but it doesn't appear easy. For example, to add 9 months to a given date, I cannot just add 9 to a month that is after April because there's no such thing as a month over 13 nor can I add 270 days to my date because that won't account for months with 31 or 28 days.

Any ideas on how to tackle this?

JakesterJakester

I thought you just needed to add one month - if it needs to be more flexible you might need to come up with a different approach. If you only need to add a month, then you can probably do an If statement to handle December. Something like

Code:
If(Month(field_name__c) = 12,
   date(year(field_name__c)+1,1,day(field_name__c),
   date(year(field_name__c),month(field_name__c)+1,day(field_name__c)
)