Pages

13 June, 2012

Format Date in Custom Display Form

Hi guys, here is another nice trick that took me a while to get.

Imagine you have a list with a Date field, only showing date value, not Time. If you create a Custom Display Form in Sharepoint Designer, you wiill see something incredible.

  1. Date field shows Time value
  2. Date field shows less 1 hour, which might lead to show one less day in date value
Just like this:
Ok the goal is to format the date value, check how I did it.


1. Edit your custom form in Sharepoint Designer
Open your custom form in Sharepoint Designer and select the date value.

2. Add a format Formula 
Click the Formula button and write the following Formula:

ddwrt:FormatDate(string(@Date), 1033, 1)
  • Don't forget to use the string function!! Will give you an error in XPath bla bla bla...
  • 1033 is the locale code, check other locale codes here List of Locale Codes
  • 1 is the date format, the possible values are 1, 4, 5, 7,12, 13 or 15, each represent a different date format, pick the one that suites you better.
3. Save the custom form and its done


If you want to keep in touch, feel free to Subscribe to How I did it - Sharepoint Foundation 2010

3 comments:

  1. This was a big help, Thanks!

    ReplyDelete
    Replies
    1. Hi jobrocol, glad it helped :)
      Checked your own blog and you also got some nice tips there, how can I register to follow you blog?

      Delete