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
karhtik palakurthikarhtik palakurthi 

moths and years

I'm getting input values as string for fields like month__c = '4' and year__C = '2009'. now I have to calcuate the the number of months and number of years then save it to the fields months__c and year__c.

example:

user input in lighning page

enter month joined =4 (months__C field)

enter year joined = 2009 (years__c field)

Output should be: 

years__c = 9

months__c = 4

how to do this? 

I also have date(StartDate__c) field which will save the date as 4/1/2009 should I use the formula field? or do I need to work this in controller class. The whole purpose is to send these fields in to the integration payload. 

 

 

 

Jolly_BirdiJolly_Birdi
Hello Karhtik

For this create a formula field, Enter this formula in it:

DATEVALUE(year__c & '-' & months__c & '-1')

Please like and mark it as best answer if it resolve your query.

Thanks,
Jolly Birdi