+ Start a Discussion
naresh johnnaresh john 

Problem with date/time

HI every one,

     When I changed the Time Zone in Personal Information of my salesforce account, I am able to see the date, time change in the records of Custom objects correctly. But when I am working on SOQL queries(On custom object records) ,I am unable to get modified date,time values. But its taking original date,time values only, 


   How to rectify this problem, so that modified date,time values may work in soql queries also.


Please let me know if you need more clarification.


Thanks in advance,




Best Answer chosen by Admin (Salesforce Developers) 

All Answers

Bhawani SharmaBhawani Sharma

By default queries returns the date and time in GMT format. You can use the format method over the Date/Date time fields. This will format the value according to the currect Locale.

naresh johnnaresh john

HI thanks for the reply.


     Can you please give me the code for the solution that you have suggested. 


That's a great help for me.



Naresh B

Bhawani SharmaBhawani Sharma

for(Account account : [Select createddate from Account])

String formattedDateTime = DateTime.format(account.createddate);

naresh johnnaresh john
This was selected as the best answer