function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Matt FolgerMatt Folger 

Transforming a date input field into a date range input field

I've got some code that grabs a date and inputs it into a SOQL query.  Looks like this:

if (ven_createdby != null && ven_createdby != ''){
                string tempven_createdby = ven_createdby;
                tempven_createdby = String.escapeSingleQuotes(tempven_createdby); //To avoid SOQL injection
                tempven_createdby = tempven_createdby.startsWith('%') ? tempven_createdby : '%' + tempven_createdby;
                tempven_createdby = tempven_createdby.endsWith('%') ? tempven_createdby : tempven_createdby + '%';
                queryString += whereOrAndClause() + ' CreatedBy.Lastname like \''+tempven_createdby+'\'';

I'd like to mod this into two field inputs, one for a lower and one for a upper end date range.  Does anyone have any tips in how I could do this?  I know there are a lot of special tidbits in relation to dates to make coding simplier. 

Something like this...

WHERE Period_Ending_Date__c >= :fromDate.Date__c AND 
               Period_Ending_Date__c <= :toDate.Date__c