Some usefull syntax with datetime

1.How to display “dd-MM-yyyy” format from database to text box ?


2. How to display “dd-MM-yyyy” with exact time from database ?

Convert.ToDateTime(ds.Tables[0].Rows[0][“NewsDate”]).ToString(“dd-MM-yyyy ss:mm:hhhh tt”);

3.How to bind “dd-MM-yyyy” in gridview ?

<asp:TextBox id=”txtCloseDate” Text='<%# Eval(“CloseDate”,”{0:dd/MM/yy}”) %>’ runat=”server” />


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: