Question: I am trying to modify the date format displayed in a custom template using the field. What I want to display is this:

> 
> This page was last modified on 29 Jan
>  2010 by Joel Spolsky
> 
> 
> 

(where the user name links to their profile).

I found some good examples here on <http://mindsharpblogs.com/aaron/archive/2008/02/08/4283.aspx> which helped me get the custom template set up. And I looked through the class members on the [MSDN documentation](http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.createdmodifiedinfo_members.aspx). But I cannot figure out how to modify the date format.

Is there any way to pass a date format string such as "**d MMM yyyy**" to the FieldValue to use for rendering?

This is my current code which works except the date format comes in as 29/01/2010 19:22 which isn't as user-friendly. 

```
<SharePoint:CreatedModifiedInfo ControlMode="Display" runat="server">
        <CustomTemplate>
            This page was last modified on
            <SharePoint:FieldValue FieldName="Modified" runat="server" ControlMode="Display" DisableInputFieldLabel="true"/>
            by
            <SharePoint:FormField FieldName="Author" runat="server" ControlMode="Display" DisableInputFieldLabel="true" />
        </CustomTemplate>
</SharePoint:CreatedModifiedInfo>

```

Answer: 
I have a preference for using XPath these days. I've run into issues using PowerShell's xml adapter that are annoying like the name collision on `item`:

```
$xml = [xml]@'
  <Users> 
    <User Name="Foo"> 
      <Friends> 
        <Friend Name="Bar"/> 
      </Friends> 
    </User> 
    <User Name="Foo2" /> 
    <User Name="Foo3"> 
      <Friends> 
        <Friend Name="Bar"/> 
      </Friends> 
    </User> 
  </Users> 
'@

Select-Xml '//User[contains(Friends/Friend/@Name, "Bar")]' $xml |%{$_.Node.Name}

```
Whilst the other answers are perfectly acceptable, I personally prefer to do it using [`SelectNodes`](https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmlnode.selectnodes).

Given the question XML in a variable `$xml`, the following will return an array.

```
$names = $xml.SelectNodes("//User[contains(Friends/Friend/@Name, 'Bar')]/@Name")

```

The `$names` variable is an `XPathNodeList` which is derived from [`XmlNodeList`](https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmlnodelist) and will output the following.

```
#text
-----
Foo
Foo3

```

If you want to grab the values, you can either iterate or grab by index. For example, `$names[1].Value` will produce `Foo3`.