How to truncate date value coming out of DB
Posted on 2007-11-15
I have a method which fills-in the TextBoxes of my control.
The problem is, the date coming out has a TimeStamp, and I don't want to display it.
Is there someway I can format the value coming out of the datarow object so that it just returns a data?
public void FillPersonalInfoFromDB(string username, string connStringName)
string userID = CommonFunctions.GetUserIdGivenUserName(username);
string sqlStatement = "select Birthdate, SSN from aspnet_PersonalInfo where UserId = '" + userID + "'";
DataSet ds = CommonFunctions.ReturnDataSet(connStringName, sqlStatement);
foreach (DataRow dr in ds.Tables.Rows)
//4/5/1974 12:00:00 AM is what this.TextBoxBirthday.Text holds after the line below runs
// I just want to show 4/5/1974
this.TextBoxBirthday.Text = dr["Birthdate"].ToString();
this.TextBoxSSN.Text = CommonFunctions.AddDashesToSSN(dr["SSN"].ToString());