how to disable displaying time in datatype smalldatetime
I have a textbox that should inserting a date in dd/MM/yyyy format. What only I can find and use is smalldatetime or datetime. I pick smalldatetime and the data displayed was like for example 01/07/2011 12:00:00 AM. Any codes involved to sort this out to be only displaying 01/07/2011 (without time)?
SqlJobMaster.InsertParameters["StartD开发者_如何学JAVAate"].DefaultValue = txtStartDate.Text.ToString();
ASP.NET
Start Date
use ToString("dd/MM/yyyy");
. Then it will get formatted the way you want it to.
I haven't used GridView
in ASP.NET, but according to this article you basically need to set the DataFormatString
property for the relevant BoundField
, e.g. to "{0:dd/MM/yyyy}"
. You should consider cultural variations though, if your app is to be used in multiple cultures: "{0:d}"
is the general "short date pattern for the current culture" format string.
something like this:
String.Format("{0:MM/dd/yyyy}", dt);
You can try :
DateTime dt = DateTime.Parse(txtDate.Text);
SqlJobMaster.InsertParameters["StartDate"].DefaultValue = dt.ToShortDateString();
精彩评论