I am using jquery fullcalendar to display records in calendar view. Currently i have a scenario where i am selecting months from vf page and i need to fetch records from controller for the selected month only.

The below javascript is giving me the start date of the month selected.

var month = $('#calendar').fullCalendar('getDate');
var f = month.format('YYYY-MM-01');

Ex - if i select Oct 2016, it gives as 2016-10-01

I need to pass this info from vf page to controller and i need to add this in my SOQL filter.


eventList = [select Id, Name, Start_Date__c,  End_Date__c   from ABC__c ]; 

In ABC__c object i have startdate & enddate as Date field which can be any date.

How to fit the selected month from vf page to this SOQL .



you can use apex:actionfunction with apex:param to pass the value


Then an actionfunction

<apex:actionfunction action="{!controllermethod} name="callactfunc" rerender="form">
      <apex:param name="datename" value="" />

And finally in your controller

public void controllermethod(){
string datevar = ApexPages.currentPage().getParameters().get('datename');
//... continue with processing

  • Hi Tushar.. Thanks for the help.. But how to design my soql as i have only startdate and enddate .. do i need to create another field..as string datevar will always have start date of every month .. – learningmode Nov 30 '16 at 4:45
  • @learningmode you can createdynamic SOQl here. like ` WHERE Start_Date__c <=: stDate AND End_Date__c >=: stDate ]` where stdate = date.valueof(datevar) – Tushar Sharma Nov 30 '16 at 5:15
  • stdate is a string variable? – learningmode Nov 30 '16 at 9:57
  • @learningmode nope date type. – Tushar Sharma Nov 30 '16 at 9:58
  • I have wriiten like 'Date stdate = date.valueof(datevar);' i am getting error 'Argument cannot be null'. – learningmode Nov 30 '16 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.