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
imrohitimrohit 

i am querying something like this

select id,createddate from someObject

and my query is returing list of sObjects with its data and Createddate
and then i am assigning this list of sobject to my attribute of lightning component like this
var action = component.get("c.getResponseHistory");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {  
                component.set("v.responseObject",response.getReturnValue());
                             
            }
         });
        $A.enqueueAction(action);
for each record i dont want to assign full datetime as createddate return datetime i want createddate to be converted to only date for each record

Please help me to do this 
Thanks
 
Best Answer chosen by imrohit
sfdcMonkey.comsfdcMonkey.com
HI Likesh, try below code :
var action = component.get("c.getResponseHistory");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") { 
              var storeResponse = response.getReturnValue();
			  var modifedList = [];
                for(var i = 0; i < storeResponse.length; i++){
                    var oDate = new Date(storeResponse[i].CreatedDate);
                    storeResponse[i].CreatedDate = oDate.getDate() + '-' +  oDate.getMonth() + '-' + oDate.getFullYear();
                    modifedList.push(storeResponse[i]);
                }

 			
                component.set("v.responseObject",modifedList);
                             
            }
         });
        $A.enqueueAction(action);
Thanks , let us know if it helps you and close your query with best answer if you got your solution 
http://sfdcMonkey.com
 

All Answers

sfdcMonkey.comsfdcMonkey.com
HI Likesh, try below code :
var action = component.get("c.getResponseHistory");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") { 
              var storeResponse = response.getReturnValue();
			  var modifedList = [];
                for(var i = 0; i < storeResponse.length; i++){
                    var oDate = new Date(storeResponse[i].CreatedDate);
                    storeResponse[i].CreatedDate = oDate.getDate() + '-' +  oDate.getMonth() + '-' + oDate.getFullYear();
                    modifedList.push(storeResponse[i]);
                }

 			
                component.set("v.responseObject",modifedList);
                             
            }
         });
        $A.enqueueAction(action);
Thanks , let us know if it helps you and close your query with best answer if you got your solution 
http://sfdcMonkey.com
 
This was selected as the best answer
imrohitimrohit
Thanks Piyush