Trying to Make a XML field that displays DateTime in "TimeOnly" format but for some reason, I can't work it how to use it, as there isn't no "TimeOnly" property shown in Intellisense when i type the following code.

  <Field ID="{GUID id}"
    Type ="DateTime"
    Format ="TimeOnly"

The error i get is

The "Format" attribute is invalid - The value 'TimeOnly' is invalid according to its datatype "http:/Schemas.microsoft.com/sharepoint/:DisplayFormat" - The Enumeration contraint failed.

  • msdn.microsoft.com/en-us/library/aa979575.aspx Here it says we can use this property format, dunno whats wrong tho Mar 12, 2012 at 12:03

3 Answers 3


SharePoint stores Time information in Universal Time Code format (UTC) which means there is no way to store the time without the date. There are ways to configure the display of a column in things like a DataView Web part to only display the time. Or you could create a calculated column that will store a string representation of the just the time. But there is no way to store just the time.

For date/time fields, the Format values are possible: DateOnly - Display (and allow edits to) only the date portion (the time portion is set to 12:00 A.M. for all edited values). DateTime - Display and edit both date and time of day (default).

  • I looked at few places on Google to find the formula for calculated column field for "TimeOnly" but couldn't fine one, unless your asking me to save time in a textcolumn. cheers Mar 12, 2012 at 13:09

The formula for time only is

TEXT([DateTimeField], "hh:mm:ss")

You can add XSL-file to your list views for format of dates or using SPD. Under Miscellaneous there is an option to add a XSL link.

I'll give you an example, I'm not an expert on XSL, but the stylesheet under works. If its the best way to do it I don't know :)

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">
    <xsl:include href="/_layouts/xsl/main.xsl"/>
    <xsl:include href="/_layouts/xsl/internal.xsl"/> 
    <xsl:template name="FieldRef_DateTime_body.DueDate" match="FieldRef[@Name='DueDate']"  mode="DateTime_body" ddwrt:dvt_mode="body">
        <xsl:param name="thisNode" select="."/>
            <xsl:value-of select="ddwrt:FormatDate(string($thisNode/@DueDate),1033,4)" />

Note the format flag used is 4 for FormatDate, which means it takes out the Time Only, not the dates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.