About this question
I'm building dynamic SOQL query for the search page I have the following code: VFP:
Apex:
My Invoice_Date__c is a date field in the object
If I execute the following code in Anonymous window I do see the correct format but with my building dynamic SOQL I see the 2017-07-17 00:00:00
Date d = s.Invoice_Date__c; string dateStr = DateTime.newInstance(d.year(),d.month(),d.day()).format('yyyy-MM-dd'); system.debug('//' + dateStr);
Dynamic query building:
if (s.Invoice_Date__c != null) { Datetime d = s.Invoice_Date__c; String dateOutput = d.format('yyyy-MM-dd'); string invoiceDateFormated = DateTime.newInstance(d.year(),d.month(),d.day()+1).format('yyyy-MM-dd'); system.debug('dateOutput: ' + dateOutput); query += ' and Invoice_Date__c = '+invoiceDateFormated ; }
other thing I have noticed that even if I select today's date which is 07/17/2017 but in debug it showing me 07/16/2017 that's why I end-up adding +1 What is salaes force dateformat?