You need to sign in to do that
Don't have an account?

Display only "date" from "datetime" field on vf page
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
Please try the below code and let us know if it works. Where instead of MyVar.Holiday_Date__C use your DateTime variable name.
Mark this as solved fi it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering similar issue.
Best Regards,
Nagendra.
Below is the code in which i am supposed to make the change.
@Nagendra It's working.
Thanks :-)