+ 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.


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. 




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.

Jolly Birdi