• Harshit Porwal 7
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi All,

I am working on a requirement where the metadata type of the field is datetime and is used in several places. However, in one of the vf pages i need to show only the "date" which needs to be extracted from datetime.

Here's what i tried :
1.) Assign the value from datetime field to a string variable to get the substring.(NOT possible to assign datetime to string)
2.)Assign the value from datetime to date. In this case i get a totally different date value i.e with a difference of almost a month.
Below is the snippet for the same.
 

datetime finishDatetime;// datetime
date finishDate; // date only


finishDatetime= sr.CKSW_BASE__Finish__c;
finishDate=finishDatetime.date();   //This gives me the value of Feb 28th when converted to date along with a string of 0's and GMT where as the original value in the backend is around March 15th.

Any suggestions would be greatly helpful.


Thanks and Regards,
Bharath Kumar M