Some usefull syntax with datetime



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

Covert.ToDateTime(ds.Tables[0].Rows[0][“NewsDate”].ToString()).ToString(“dd-MM-yyyy”);

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” />

Advertisement

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.