Guys i am unable to convert datetime to \"dd-MMM-yyyy\" format. My code is given below:
TreeNode tn = new TreeNode(dr[\"pBillDate\"].ToString()); // He
Try this code:
string formattedDate = YourDate.ToString("dd MMM yyyy");
It will format to like:
12 Nov 2012
Find below code:
DateTime todayDay = DateTime.Today.ToString();
It will provide you with dd-MMM-yyyy
format.
try Following
TreeNode tn = new TreeNode(dr["pBillDate"].ToShortDateString());
it can convert DateTime to Date
Thanks,
DateTime StartDate = Convert.ToDateTime(datepicker.Text);
string Date = StartDate.ToString("dd-MMM-yyyy");
The following couple examples should work:
DateTime dt = Convert.ToDateTime(dr["pBillDate"]);
TreeNode tn = new TreeNode(String.Format("{0:dd-MMM-yyyy}", dt));
or
DateTime dt = Convert.ToDateTime(dr["pBillDate"]);
TreeNode tn = new TreeNode(dt.ToString("dd-MMM-yyyy"));