SharePoint Use Cases

07 Jan, 2009

Customizing DateTime format on a list view web part

Posted by: Toni Frankola In: SharePoint  Bookmark and Share

In order to make SharePoint really functional sometimes little things count. Few weeks ago a customer wanted to display only Date partition of Created value in a list view web part.

Let’s say I want to display a list of “My Active Tasks” on a list web part.

m1

The time partition of the information is irrelevant for this web part. Time is just using space we need to display Title.

SharePoint does not allow you to format the output in a list view web part. Here is a little trick on how to fix that.

    • Create a new calculated column for your list (single line of text)
    • Use the following formula to calculate its value
      =TEXT(Created,"dd mmm yy")

      Use the new column to display in your list. It will look like this one:

      m2

      Paul Grenier wrote a post about similar problem. He used a JQuery to modify Calendar View. It looks like this:




      Comments

      2 | backtrack

      February 5th, 2009 at 3:38 am

      Avatar

      Hi,
      I’d like to have displayed on the calendar view the Creator (Created By) and another field like Location.
      The problem is that is not possible to choose Created By in a calculated column.

      andrew

      3 | Toni

      February 6th, 2009 at 1:37 pm

      Avatar

      @Andrew: Take a look at this solution http://www.endusersharepoint.com/?p=1223, by Paul Grenier… it could be used to solve your problem.

      4 | Wouter

      February 13th, 2009 at 5:05 am

      Avatar

      I tried this, but I get this message every time:

      The formula contains a syntax error or is not supported. at Microsoft.SharePoint.Library.SPRequestInternalClass.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd)
      at Microsoft.SharePoint.Library.SPRequest.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd)

      Any ideas?

      5 | Toni

      February 14th, 2009 at 11:11 am

      Avatar

      @Wouter: Which regional settings you are using?

      6 | Wouter

      March 2nd, 2009 at 5:26 am

      Avatar

      Toni, I’m using dutch (belgium)

      9 | Toni Frankola

      March 14th, 2009 at 5:59 am

      Avatar

      @Wouter: I just tried it with Croatian and Dutch (Belgium) regional settings and it works. Maybe something else is missing? Can you save your list as template as send it to me?

      10 | Nick Orlich

      September 11th, 2009 at 12:57 pm

      Avatar

      Can you use this method to get the time to display under the date?

      11 | Toni Frankola

      September 14th, 2009 at 12:00 pm

      Avatar

      @Nick: Sure, try “=TEXT(Created,”hh:mm:ss”)”

      12 | K. Ramya

      September 25th, 2009 at 3:38 am

      Avatar

      in share point portal i want to diaplay only day & Month.. year not required.

      Pls suggest..

      13 | Toni Frankola

      September 28th, 2009 at 1:02 am

      Avatar

      @K.Ramya:

      =TEXT(Created,”dd mmm”)

      14 | Daniel Walker

      October 5th, 2009 at 8:58 am

      Avatar

      If you are in control of the list schema you can set the date format as DateOnly and this will eliminate the time from the views.

      type=”DateTime” format=”DateOnly”

      15 | Jo

      October 12th, 2009 at 2:14 am

      Avatar

      But what if you make a calculated field with the formula =TEXT(Created,”dd mmm”). Is it still date sortable like it should be?

      16 | Toni Frankola

      October 12th, 2009 at 3:00 am

      Avatar

      @Jo: Nope, it is text field and it will be sorted as text. I think you cannot have both ways OOTB.

      17 | chirantan

      November 23rd, 2009 at 7:24 am

      Avatar

      This is really very small and effective solution. this solved my problem in seconds.

      Thanks

      Comment Form



      About

      Real-life use case and opinions about collaboration, CRM and web technologies and stuff by Toni Frankola. More...

      Categories

      All postings on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer.