Friday 17 June 2011

Removing the time value from the date/time column in a view

I've finally found time to get back onto the TechNet forums and just happened to land on this post with a brilliant answer from Aaron Croasmun:
http://social.technet.microsoft.com/Forums/en-US/systemcenterservicemanager/thread/62ce2f7e-12ca-44c9-b813-0a571c8fee36

I had been meaning to find this out for myself for a while now as it's annoying seeing dd/mm/yy 00:00:00 in my views in the asset management solution I did.

<mux:Column Name="$TimeAdded$" DisplayMemberBinding="{Binding Path=$TimeAdded$}" Width="100" DisplayName="TimeAdded.View.DisplayName" Property="$TimeAdded$" DataType="s:DateTime" />

Is changed to:

<mux:Column Name="$TimeAdded$" DisplayMemberBinding="{Binding Path=$TimeAdded$, StringFormat=d}" Width="100" DisplayName="TimeAdded.View.DisplayName" Property="$TimeAdded$" DataType="s:DateTime" />

Notice the "DisplayMemberBinding" has the StringFormat=d appended

So before it looked like this:


And then ends up like this after the MP edit:

No comments: