You need to sign in to do that
Don't have an account?
Vamsi
how to use custom labels with datetime fields
Hi,
I have a soql query where I am using custom labels to specify the date range in string example : THIS_WEEK or something else in future and binding it to the lastmodified date time. when I bind it throws me the below error any thoughts would be appreciated.
In apex
soql query : Select status ,CaseNumber,Priority from case where LastModifiedDate =:Label.Thisweek (Thisweek contains a value : THIS_WEEK)
error : Invalid bind expression type of String for column of type Datetime
I have a soql query where I am using custom labels to specify the date range in string example : THIS_WEEK or something else in future and binding it to the lastmodified date time. when I bind it throws me the below error any thoughts would be appreciated.
In apex
soql query : Select status ,CaseNumber,Priority from case where LastModifiedDate =:Label.Thisweek (Thisweek contains a value : THIS_WEEK)
error : Invalid bind expression type of String for column of type Datetime
Please find below details:-
String str='THIS_WEEK';
String q='Select status ,CaseNumber,Priority,Response_Due_Date__c,Response_time_elapsed__c from case where RecordTypeID = \'012300000067hjh\' AND (Status = \'Unclaimed\' OR Status =\'Escalated\' OR Status =\'Rep On\') AND Product_Type__c = \'Test\' AND OwnerID = \'00G30000003hjg\' AND LastModifiedDate = '+str +' LIMIT 50000';
List<case>= Database.getQueryLocator(q);
Thanks,
Rajnish
All Answers
use below Datetime class for your reference.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_datetime.htm
You need to typecast to convert the string to DateTime.
Thanks and Regards
sandhya
Pass your string value in String query and then put it into get query method. It will return you the list.
string query='create your query string here';
List<>= Database.getQueryLocator(query);
Hope this will help you.
Contact me on bishnoi.rajnish@gmail.com for further assistance.
Thanks
Please find below details:-
String str='THIS_WEEK';
String q='Select status ,CaseNumber,Priority,Response_Due_Date__c,Response_time_elapsed__c from case where RecordTypeID = \'012300000067hjh\' AND (Status = \'Unclaimed\' OR Status =\'Escalated\' OR Status =\'Rep On\') AND Product_Type__c = \'Test\' AND OwnerID = \'00G30000003hjg\' AND LastModifiedDate = '+str +' LIMIT 50000';
List<case>= Database.getQueryLocator(q);
Thanks,
Rajnish
Thank you, The above query is working ..