Click here to Skip to main content
15,891,921 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,

I want to show Time(hh:mm AM/PM) only from Table Data (DataType:DateTime),it is like '2011-08-30 00:00:00.000'
it shows correct in GridView : using DataFormatString="{0:hh:mm}"
<asp:BoundField DataField="E_time" HeaderText="Time" DataFormatString="{0:hh:mm}"/>

Similarly I want to display Time in Label
<asp:Label ID="Label1" runat="server"></asp:Label>

How I can Format it.
Posted
Updated 12-Sep-11 0:51am
v2

ASP.NET
<asp:boundfield datafield="E_time" headertext="Time" dataformatstring="{0:hh:mm tt}" xmlns:asp="#unknown" />
 
Share this answer
 
Comments
LebneizTech 12-Sep-11 7:01am    
thanks
C#
label1.Text = myDateTime.ToString("hh:mm tt");
 
Share this answer
 
Comments
LebneizTech 12-Sep-11 6:59am    
Sir, I am using Label in <asp:DataList, so it should in Aspx side

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900