I am able to evaluate today's date using:
String timeframe = DateTime.newInstance(Date.today(), Time.newInstance(0, 0, 0, 0)).format('yyyy-dd-MM');
But I need to add days to this. So I want:
String timeframe = DateTime.newInstance(Date.today()**.addDays(10)**, Time.newInstance(0, 0, 0, 0)).format('yyyy-dd-MM');
query += ' and (created_date__c <= ' + timeframe + ')';
But am receiving this error: line 1:392 no viable alternative at character '2'
I also tried:
DateTime refDate1 = DateTime.newInstance(System.today().year(), System.today().month(), System.today().day(), 0, 0, 0);
DateTime refDate2 = refDate1.addDays(-10);
query += ' and created_date__c <= '+ refDate1.date() + ' and created_date__c >= ' + refDate2.date();
Which throws: line 1:405 no viable alternative at character ' '
Please help!