ASP.NET - how to insert only date in database in "dd/MM/yyyy" format using c#

Asked By bhanupratap singh on 02-Aug-12 10:09 AM
I have sql server 2008. I want to insert only date into table in "dd/MM/yyyy" format, not time. i m getting date value from
user txtDate.Text. How to do it
Peter Bromberg replied to bhanupratap singh on 02-Aug-12 03:44 PM
If the column is of type datetime in the database, then it is always going to have a time component even if you do not provide it. Just use
DateTime myDate = DateTime.Parse(txtDate.Text);
and insert the value as a DateTime object.
bhanupratap singh replied to Peter Bromberg on 03-Aug-12 01:03 AM
I have date column in my table of data type is date not datetime. So I need to insert only date that too in "dd/MM/yyyy" format.