You need to sign in to do that
Don't have an account?
ShaikA
Soql DateTime queried result and actual dateTime showing different
Hi All,
I have two Date/Time fields : StartTime and EndTime, When queried it result is not correct. It is showing diffrent than actual.
Entered Date:
Qureid Result Date:
mRoomObj.Start_Date__c>> 2018-10-02 22:00:00
mRoomObj.End_Date__c>> 2018-10-03 00:00:00
Please help me how i can fix this issue
Thanks in Advance
Shaik
I have two Date/Time fields : StartTime and EndTime, When queried it result is not correct. It is showing diffrent than actual.
Entered Date:
Qureid Result Date:
mRoomObj.Start_Date__c>> 2018-10-02 22:00:00
mRoomObj.End_Date__c>> 2018-10-03 00:00:00
Please help me how i can fix this issue
Thanks in Advance
Shaik
From documentation:
dateTime field values are stored as Coordinated Universal Time (UTC). When a dateTime value is returned in Salesforce, it’s adjusted for the time zone specified in your org preferences. SOQL queries, however, return dateTime field values as UTC values. If you want to process these values in different time zones, your application might need to handle the conversion.
So it is possible that when you're storing date in Salesforce it's getting converted into UTC format and that's why it is returning in that format only. You can convert that dateTime into different time zones as per your need.
Also, try the below approach: And then we need to add offset to the retrieved values.
Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra
Below Sample code can fulfill your requirements. Hope this will work for you.
Datetime now = Datetime.now();
Integer offset = UserInfo.getTimezone().getOffset(now);
Datetime local = now.addSeconds(offset/1000);
Please mark this as best answer if this solves your problem.
Thank you,
Ajay Dubedi