+ Start a Discussion
SF DEVSF DEV 

How to get Month from a date field

c.Contract_Start_Date__c

 

this id a date field type.

 

I need to get month from the above date in trigger code.

 

Eg: c.Contract_Start_Date__c =13/12/2012

 

then i need Month= DEC 

Best Answer chosen by Admin (Salesforce Developers) 
vishal@forcevishal@force

Integer dtMonth = c.Contract_Start_Date__c.month();

 

The method ".month()" returns an integer, so if your date is 11/11/2012, it will return you '11'.  To get the Month Name, write some logic that returns you the month name when you pass the month number to it. 

 

Make a habit of referring the developer guides before directly posting queries here. Will help you learn in a better way :)

All Answers

vishal@forcevishal@force

Integer dtMonth = c.Contract_Start_Date__c.month();

 

The method ".month()" returns an integer, so if your date is 11/11/2012, it will return you '11'.  To get the Month Name, write some logic that returns you the month name when you pass the month number to it. 

 

Make a habit of referring the developer guides before directly posting queries here. Will help you learn in a better way :)

This was selected as the best answer
SF DEVSF DEV

Yes, i referred.....i have resolved it

 

date d=c.c.Contract_Start_Date__c;

Integer dtMonth = d.month();