+ Start a Discussion

To get Month Number from format like mm/dd/yyyy hh/mm AM/PM

Hi All ,


 I have one case field lke the format "mm/dd/yyyy  hh:mm AM/PM"  i.e(3/7/2012 5:07 AM).From this i want to get month value.i.e here 3.How can i get this.


 I tried this way

MONTH(DATEVALUE(c.CaseCreated__c)), but it is giving an error "Incorrect parameter for function 'DATEVALUE()'. Expected Text, received java.util.GregorianCalendar".


I con't get solution for this.please help.! Any help greatly appreciated:)


Use Date.valueOF(date time) and ther capture month or what you want to get from Date.

Please mark it as accepted if it is a solution.


Hi Mohi,



Thank you for replying....


My problem is:


   <apex:column headerValue="Case Number" rendered="{!IF((VALUE(monthval)=MONTH(DateValue(c.CaseCreated__c))),true,false)}">                                                                                                       
<apex:outputField value="{!c.Name}"/>  </apex:column>


 for example monthval=march; i.e 3.

   This 3 equals to month value of that date.Then do the operation.


My require ment is


 In IF condition   (VALUE(monthval)  =  MONTH(DateValue(c.CaseCreated__c)),true,false).


The Bold colored function  here is not getting Month value from the DateTime Field.


Note:This is in Visual Force page only not in Apex logic.I want to convert it in VF Script and get the Month value.


Please help.....waiting for ur reply !:)










The Month bold letter you have mention works only for Date kind of Data not DateTime.

Did you Check == in place of =