How to remove time in second after retrieve from database?

i have this label retrieve time from database and display in label. but time in database also consist of second for example 03:45:29, how can i remove the time in second to become 03:45 in the label after retrieve it. this is my code:LabelDateMarker.Text = LabelDateMarker.Text + " " + dr[3].ToString();

Jon Skeet
people
quotationmark

Assuming dr is a SqlDataReader or similar, you probably want to cast to DateTime, then format the value appropriately:

DateTime dateTime = (DateTime) dr[3];
string formatted = dateTime.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
LabelDateMarker.Text += " " + formatted;

Here yyyy-MM-dd HH:mm is a custom date/time format string indicating that you want the hours and minutes after the ISO-8601-formatted date part.

I've used the invariant culture when formatting to avoid this giving unexpected results in locales that don't use the Gregorian calendar by default.

(I've assumed the value is always non-null. If it might be null, you should check it with dr.IsDBNull(3) first.)

people

See more on this question at Stackoverflow