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
bdr_09bdr_09 

How can i retieve month from the created date of any object ?

Hello,

         How can i retieve month from the created date of any object in soql or in apex ?

 

Thanks,

--bdr

micwamicwa

Try this:

 

 

Account a = [Select a.CreatedDate from Account a limit 1]; Integer month = a.CreatedDate.month();

 

 

 

kerwintangkerwintang

Another solution is to create a new formula field which contains your month value. The formula will be

MONTH(DATEVALUE(CreatedDate))

 

Thanks and Best Regards,

Kerwin