+ Start a Discussion

Trigger to find the year and month of a particular date



I Need to display year and day of a particular date..


I have three fields.

Suppose in first field i have entered 1/05/2011




In second filed month has to display like(jan or feb or march,.............)


In third field year has to diplay (2011)



Please can any one help me out..??


Thanks & Regards,



Ritesh AswaneyRitesh Aswaney


Datetime dateinst = Date.today();
System.debug (dateinst.format('EEEE  dd MMM yyyy'));
Prints  the following output :
Friday  06 May 2011



In date type field there are methods to get year,Month and day of particular month.If date is date/time field in this case you have an option to format the date using datetime.format() methods.


For more information go through the Apex guide page no 209.