function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pankaj PariharPankaj Parihar 

sapreat date from createdby

User-added image
hi friends 
i wanted to acess date and time  separately how can i get it
through batch code
sfdcMonkey.comsfdcMonkey.com
Hi Pankaj.
trye like below :

String sDate = String.valueOf(obj.createdDate.date() ;
String sTime= String.valueOf(obj.createdDate.time() ;

 here is the sample code :
 
List<account> acc = [select id, createdDate from account LIMIT 1];


system.debug(String.valueOf(acc[0].createdDate.date())); 
system.debug(String.valueOf(acc[0].createdDate.time()));

i hope it helps you.
      Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
    thanks
    http://sfdcmonkey.com
v varaprasadv varaprasad
Hi Pankaj,

Please check once below sample code it may help you.
 
list<account> acccs = [SELECT Id,createddate,createdbyid
                       FROM account limit 10];

Map<date,Long> mapDat = new Map<date,Long>();

for(account acc : acccs){
    DateTime dt = acc.createddate;
    Date myDate = dt.date();
    Long gettime = dt.getTime();
    mapDat.put(myDate,gettime);
}
system.debug('==Date=='+mapDat.keyset()+'==Time=='+mapDat.values());

Hope this helps you.



Thanks
Varaprasad
Pankaj PariharPankaj Parihar
hi piush
can u help me in this batch program same createdby date related
Assign all the leads created during non-business hours to specified queue and leads created during business hours to specified queue.
sfdcMonkey.comsfdcMonkey.com
Hi pankaj, please put a new query on forum regarding to your new requrement in proper details, so everyone can take a look into this, and close your this query by choosing best answer so it will make proper solution for others in future.
Thanks
Ramakrishna Reddy GouniRamakrishna Reddy Gouni
[select Id, createdById, createdBy.Name, createdDate from Contact];
[select Id, createdById, createdBy.Name, createdDate from Account];
[select Id, createdById, createdBy.Name, createdDate from Opportunity];
i tried few object, all are working