Skip to main content

Posts

Showing posts with the label how to compare value with date time variable in dynamic query in salesforce

How to use Date Time Variable in Dynamic Query

In some scenario you might have come across to fetch record with in some date time range.  Here I am sharing some code for this. Suppose I am querying records from Minutes Object. There is two field Start_Time and End_Time present  in Minutes Object. This is my page    <apex:inputField value="{!minute.Start_Time__c}" required="true" label="From Date"/>  <apex:inputField value="{!minuteObj.End_Time__c}" required="true" label="To Date"/> <apex:commandButton action="{!convertValidMinutesToUsage}" value="Process Minute's"/> This is my controller  public with sharing class ControllerValidMinutesToUsage {      public Minute__c minute{get;set;}      DateTime startDate;      DateTime endDate;      string query;      public ControllerValidMinutesToUsage(){             minute =  new Minute__c();     } ...