Store current date in database

sadesh kumar asked on May 30, 2014 02:12

I have retrived date field data from SQL database Table and displayed using user control web parts but the default time also displayed, Then how to display the date field only.I have used the following codes: SqlCommand cm = new SqlCommand(" INSERT INTO jobpost ( postedon) values ('" +DateTime.Now.ToShortDateString() + "')

Recent Answers

Brenden Kehren answered on May 30, 2014 06:19

Depending on your version of SQL Server, you may not have the opportunity to store only the date. So assuming that is the case and you're using a datetiem datatype, you can format the output in your transformation using

<%# FormatDateTime(Eval("YourDateField"), "d") %>

This would return 05/30/2014

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.