+ Start a Discussion
grandak koygrandak koy 

Workflow to Fire when Date changes to previous Month?

How can I set off a field update when a date's month changes to the previous month?

Ex. if the date is 5/1/2018, and it changes to 4/2018, i need a field to update. I currently have this:

AND(
ISCHANGED(Date__c),
date__c < (PRIORVALUE(date__c) - 30)
)
KdKomalKdKomal
Hi,

Please try 

AND( 
ISCHANGED(date__c ), 
MONTH( PRIORVALUE(date__c ) ) > MONTH(date__c ) 
).

Please mark this as the best answer if it resolves your issue.

Note :- The field should be of Date type. If it is datetime user DATAVALUE() first and then use the above mentioned formula.
Raj VakatiRaj Vakati
It will not work because you can't able to use ISCHANGED on the date field and second think MONTH( PRIORVALUE(date__c ) )  will not support .. you need to write the trigger to do It.. 
grandak koygrandak koy

AND( 
ISCHANGED(date__c ), 
PRIORVALUE(Month(Datevalue(date__c )))) > MONTH(Datevalue(date__c ))

it says incorrect arguement type for function priorvalue
Raj VakatiRaj Vakati
It will not work because you can't able to use ISCHANGED on the date field and second think MONTH( PRIORVALUE(date__c ) )  will not support .. you need to write the trigger to do It.. 
grandak koygrandak koy
You can use ISCHANGED on the date field. but yes, priorvalue isnt working. 
User-added image
Raj VakatiRaj Vakati
  1. Its my mistake then ..  prior value will not work .. that is the only way to check old and new values in workflow 
  2. I tried to do with formulas .. even not work 
  3. The simple option is the trigger 

 
KdKomalKdKomal
@Raj,

Thank you for your inputs.

Hi Grandak,

If it has to be a declartive approach, create one formula field and then get the dateValue of the datetime field and store it as date type.

Then use that field in the above formula.

If programmatic approach is an option you can go with it as well.
Raj VakatiRaj Vakati
the formula will not work on workflows .. and you can't trigger the workflow based on the formula changes 
grandak koygrandak koy
I created a second field to hold the month value
Raj VakatiRaj Vakati
It is formula ???Or just number filed ? 
If it a formula it will not work .. 
KdKomalKdKomal
Hi raj it's a formula field of type date  I implemented this and it worked just fine. 
KdKomalKdKomal
The work flow will still be fired from the change of datetime field  The formula field is just for the computation in the backend. 
grandak koygrandak koy
Hi KD,

Can I see what you wrote to trigger it?
KdKomalKdKomal
Hi,

Please refer the below screenshot.

I Created a Datetime field ttt__c.
I Created a formula field fff_c of type date and got the value using DATAVALUE(ttt__c).

Created a workflow with the rule criteria as below. Please let me know if it helps.
User-added image