Reply
Regular Contributor
street9
Posts: 94
0
Accepted Solution

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 

Trusted Contributor
vishal@force
Posts: 427
0

Re: How to get Month from a date field

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 :)

Vishal, Certified Developer and Administrator
Kudos a post if it helps, mark it as solution if it solves.
http://exploretheforce.blogspot.in
Regular Contributor
street9
Posts: 94
0

Re: How to get Month from a date field

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

 

date d=c.c.Contract_Start_Date__c;

Integer dtMonth = d.month();