Thursday, April 19, 2012

How to format a varchar in a gridview in military time to standard time

There is a varchar column in the database table in this format of military time 1230 or 1750 or 1320 and that field get populated into a gridview in asp. I need to convert that string to standard time. I have tried the DateFormatString and nothing seems to work.



the asp is



<asp:BoundColumn DataField="ScanTime" SortExpression="ScanTime" ReadOnly="True" 
HeaderText="Scan Time" DataFormatString="{0:hh}:{0:mm} {tt}">
<ItemStyle Width="80px"></ItemStyle>
</asp:BoundColumn>


that DateFormatString causes Input string was not in a correct format. error.



Please help I have tried combinations of hh:mm and things like that but since its a varchar I think its failing





No comments:

Post a Comment