开发者

How to format a SharePoint ListItemProperty Date Field

I've got a SharePoint (2010) list with a date field on it.

Now in my custom display form I can go ahead and add the field

<SharePoint:ListItemProperty Property="MyDateFie开发者_如何转开发ld" runat="server" id="ListItemProperty1" />

which results in the following output

21.02.2011 15:44

How can I tell SharePoint to format the Date to

21.02.2011

The only way so far seems to be to create a new calculated column based on that date field and do the formatting within the field definition, but that kind of seems to be the wrong way.

Any help would be much appreciated.


When you create the "Date" column in the list, there is option to select: 1)Date only ; 2)Date and time. If you select the first option, then in the display form, only the date is shown


I had a similar task to perform recently, but the client wanted the time stored as well as date, just not to display the date.

The way I got around this was to create a Calculated Column which displayed the date in the format required, and I then just pointed my field control to display that column.

The calculated column had this formula:

=TEXT([News Article Date],"dd MMMM yyyy")

FYI: this was in a page layout.


Please see http://panvega.wordpress.com/2008/12/08/ddwrtformatdate-with-different-formatflags/ for custom pages.


programmatically (powershell):

$web = get-spweb http://thingy/
$list = $web.lists["List Name"]
$datefield = $list.fields["Date Field"]
$datefield.displayformat = [microsoft.sharepoint.spdatetimefieldformattype]::dateonly
$datefield.update()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜