Convert Date to “dd-MMM-yyyy” format c#

后端 未结 5 1377
名媛妹妹
名媛妹妹 2021-01-17 09:15

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         


        
5条回答
  •  攒了一身酷
    2021-01-17 10:19

    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"));
    

提交回复
热议问题