You need to sign in to do that
Don't have an account?
Gheorghe Sima 25
How to use a date field in a query?
Hi,
I want to make a query with some parameters, but i don't know how to use a date field in it.
This is my code:
I recive the error : unexpected token: '/'. I also use the following sintax: myQuery += ' Start_Date__c = ' + myVisit.Start_Date__c, but it doesn't work.
Can anyone help me?
I want to make a query with some parameters, but i don't know how to use a date field in it.
This is my code:
myQuery = 'select Name, Start_Date__c, Contact__c, Country__c, Data_Check_In__c, Data_Check_Out__c,Id from Visit__c'; if(myVisit.Start_Date__c != null || myVisit.Country__c != null) myQuery += ' where '; if (myVisit.Start_Date__c != null) { myQuery += ' Start_Date__c = ' + String.ValueOf(myVisit.Start_Date__c.day()) + '/' + String.ValueOf(myVisit.Start_Date__c.month()) + '/' + String.ValueOf(myVisit.Start_Date__c.year()); if(myVisit.Country__c != null) myQuery+=' and '; } if(myVisit.Country__c != null) { myQuery += ' Country__c = \'' + myVisit.Country__c + '\''; } myQuery += ' LIMIT 20';
I recive the error : unexpected token: '/'. I also use the following sintax: myQuery += ' Start_Date__c = ' + myVisit.Start_Date__c, but it doesn't work.
Can anyone help me?