Reputation: 25
So I am trying to get the date from my database table and display it in a label text. I am using this code:
this.label011.Text = myReader.GetString("Registration_Date");
It works, but when it displays the data, it shows as EX. 2/10/2017 12:00AM. I only wish to see the date only not time. The data stored in the table is "2/10/2017", why is it posting 12:00AM with it?
Upvotes: 0
Views: 469
Reputation: 68687
The data is stored as a DateTime
. You'll need to format it in order to display correctly
((DateTime)myReader["Registration_Date"]).ToShortDateString();
or
myReader.GetDateTime("Registration_Date").ToShortDateString();
Upvotes: 1