(I am sure there would be other methods, but one which worked for me( I didn't look further). you need to get a date to use in dynamic query.)
//Create a datetime
Datetime dtDate = Datetime.newinstanceGmt(2011,5,21,0,0,0);
// Change the format according to your need and get the date as a string
string dateCh = dtDate.format('yyyy-MM-dd');
string otherdate = dtDate.format('dd-MM-yyyy');
(this was no big deal but if you need to get a datetime for a query(SOQL) this method would be very useful.)
string cdDateCh = dtDate.format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');
ex.-
List = [select name, Account.name from Contact where createdDate > :cdDateCh];
//Create a datetime
Datetime dtDate = Datetime.newinstanceGmt(2011,5,21,0,0,0);
// Change the format according to your need and get the date as a string
string dateCh = dtDate.format('yyyy-MM-dd');
string otherdate = dtDate.format('dd-MM-yyyy');
(this was no big deal but if you need to get a datetime for a query(SOQL) this method would be very useful.)
string cdDateCh = dtDate.format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');
ex.-
List
No comments:
Post a Comment