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
Sivasankar G 14Sivasankar G 14 

Set formula for date field to start of the month

I want to set the formula to set the start date for billing for start of month of always and similarly to set the end date of billing to end of the month. How can i do this.?
Vanisha_GuptaVanisha_Gupta
Hello,

Please give it a try:
Start Date -->
DATE(YEAR(BillingDate__c),MONTH(BillingDate__c),1)
End Date --> 
DATE(
    YEAR( BillingDate__c ) ,
    Month( BillingDate__c),
    CASE( MONTH(BillingDate__c), 
        1, 31, 
        2, IF( MOD( YEAR(BillingDate__c) , 4) = 0, 29, 28), 
        3, 31, 
        4, 30, 
        5, 31, 
        6, 30, 
        7, 31, 
        8, 31, 
        9, 30, 
        10, 31, 
        11, 30, 
        12, 31, 
        0 
    )
)
Let me know if it works!
 
Vanisha_GuptaVanisha_Gupta
+ Another short way i found for Last date(find the first day of the next month and subtract a day) :
IF(
  MONTH( BillingDate__c) = 12,
  DATE( YEAR( BillingDate__c ), 12, 31 ),
  DATE( YEAR( BillingDate__c), MONTH ( BillingDate__c) + 1, 1 ) - 1 
)