Friday, October 19, 2012

Custome format of DateTime in WPF Data Grid


If we want to show only date and skip the time part
 
<DataGridTextColumn Header="Entry Date" Width="*" Binding="{Binding Path=DATE,StringFormat=\{0:dd.MM.yyyy \}}" >
</DataGridTextColumn >

Result is e.g. 19.10.2012

<DataGridTextColumn Header="Entry Date" Width="*" Binding="{Binding Path=DATE,StringFormat=\{0:dd.MM.yy \}}" >
</DataGridTextColumn >

Result is e.g. 19.10.12

<DataGridTextColumn Header="Entry Date" Width="*" Binding="{Binding Path=DATE,StringFormat=\{0:dd.MM.yy \}}" >
</DataGridTextColumn >

Result is e.g. 10.19.12



OR we can show only time without Date like
 

<DataGridTextColumn Header="Entry Date" Width="*" Binding="{Binding Path=DATE,StringFormat=\{0:HH.mm.ss \}}" >
</DataGridTextColumn >

Result will be like  22:19:33


No comments:

Post a Comment