Shweta68

Shweta68

  • 1.7k
  • 99
  • 1.1k

Remove Datetime By query to show inLabel or Textbox

Aug 24 2018 1:17 PM
Hello
 I have a column RegDate(Datetime). When I select it by query then it gives me data like : 2018-08-23 23:42:48.300
 I need to display the Date only. For this I write following code its working properly.
 
string RegDate = dt1.Rows[0]["RegDate"].ToString();
DateTime dRegDate = Convert.ToDateTime(RegDate);
lblRegDate.Text = dRegDate.ToString("dd MMM yyyy"); 
 
Can I solve it in one line or I can change it by query?
 
Kindly help me.

Answers (4)