4

Start and End Dates need to be calculated date fields (formula) based on the Fiscal_Year_Start_Date__c field on the Account and the Fiscal_Year__c.
Example: If Fiscal_Year__c = 2013 and Account.Fiscal_Year_Start_Date__c = 7/1/1990, Start Date = 7/1/2013 and End Date = 6/30/2014

Fiscal_Year__c is of type Picklist Fiscal_Year_Start_Date__c is Formula field

1 Answer 1

4

How about as a start.

startDate:

DATE(VALUE(TEXT(Fiscal_Year__c)),MONTH(Fiscal_Year_Start_Date__c),DAY(Fiscal_Year_Start_Date__c))

endDate is a bit more problematic in a formula field. In Apex you could just do a addDays(-1) to get the EndDate and cleanly roll around months and years. In a formula field you are probably going to need a combination of CASE, IF and MOD statements.

You might be able to do some arithmetic based on 1440 being the number of hours is a day, but I haven't tried it yet.

See Adding Days, Months, and Years to a Date

I haven't tried it, but maybe the following will work.

DATE(VALUE(TEXT(Fiscal_Year__c)),MONTH(Fiscal_Year_Start_Date__c),DAY(Fiscal_Year_Start_Date__c)) - 1
5
  • Fiscal_Year__c is a field type of picklist
    – sfdc
    Commented Dec 5, 2013 at 20:55
  • @sf.dev I've added VALUE() to the formula to convert the picklist value to a number. Commented Dec 5, 2013 at 20:58
  • I am getting an error .Error: Field Fiscal_Year__c is a picklist field. Picklist fields are only supported in certain functions.
    – sfdc
    Commented Dec 5, 2013 at 21:18
  • 1
    @sf.dev might need to convert it to text first. I'll update the answer. Commented Dec 5, 2013 at 21:20
  • @DanielBallinger Great Work, Can you help me to resolve my question salesforce.stackexchange.com/questions/237892/…
    – Ragul
    Commented Oct 31, 2018 at 11:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .