I am curious if the following task can be done declaratively without Apex code. For our billing object we have the following fields:
payment_method <- Picklist with various values. I'm looking for (Credit|Debit) card_expiration <- String with the card expiration in the MM/YYYY format
I'm considering adding a new card_expiration_date field that uses a formula to check if the payment_method is Credit or Debit. If that is true then parse the card_expiration to yield the last day of the month in the year given.
The challenge here is to calculate the date accurately with regard to months ending with 28, 29, 30 or 31 days. If I want to pursue exact accuracy this could very well require me to dip in to Apex, which I'm actually more comfortable working in. However, the purpose for this is to identify whose cards are about to expire and email out a notification. We just need to get close. Since all months have 28 days, could this be done more simply with a formula field? In other words if I have the following data:
01/2016 --> formula yields 01/28/2016 02/2016 --> formula yields 02/28/2016 03/2016 --> formula yields 03/28/2016
What do you think?