Date Time in c#
-
Hello Friends, I am facing some problem in Date Time in c#. I wrote program like this string strdt= "06/19/2006"; //mm/dd/yyyy DateTime dt= Convert.ToDateTime(strdt).ToString("d") ; When I execute this then I get value in dt like "6/19/2006" But, Actually I need value in dt "06/19/2006" in this format. I mean to say Zero with Six. How can I solve this problem? Any help is appreciated Thanks, Rajesh rajesh
-
Hello Friends, I am facing some problem in Date Time in c#. I wrote program like this string strdt= "06/19/2006"; //mm/dd/yyyy DateTime dt= Convert.ToDateTime(strdt).ToString("d") ; When I execute this then I get value in dt like "6/19/2006" But, Actually I need value in dt "06/19/2006" in this format. I mean to say Zero with Six. How can I solve this problem? Any help is appreciated Thanks, Rajesh rajesh
-
Hello Friends, I am facing some problem in Date Time in c#. I wrote program like this string strdt= "06/19/2006"; //mm/dd/yyyy DateTime dt= Convert.ToDateTime(strdt).ToString("d") ; When I execute this then I get value in dt like "6/19/2006" But, Actually I need value in dt "06/19/2006" in this format. I mean to say Zero with Six. How can I solve this problem? Any help is appreciated Thanks, Rajesh rajesh
If you look at the documentation it states that if the day is a single digit it will be returned as a single digit. I would think it doesn't matter how it is stored internally, but how it is displayed. If you want a day to be displayed with a leading zero, use "dd" in the format string. Here is the link from the MS help files: ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconcustomdatetimeformatstrings.htm HTH Gandalf
-
Hello Friends, I am facing some problem in Date Time in c#. I wrote program like this string strdt= "06/19/2006"; //mm/dd/yyyy DateTime dt= Convert.ToDateTime(strdt).ToString("d") ; When I execute this then I get value in dt like "6/19/2006" But, Actually I need value in dt "06/19/2006" in this format. I mean to say Zero with Six. How can I solve this problem? Any help is appreciated Thanks, Rajesh rajesh
-
Hello Friends, I am facing some problem in Date Time in c#. I wrote program like this string strdt= "06/19/2006"; //mm/dd/yyyy DateTime dt= Convert.ToDateTime(strdt).ToString("d") ; When I execute this then I get value in dt like "6/19/2006" But, Actually I need value in dt "06/19/2006" in this format. I mean to say Zero with Six. How can I solve this problem? Any help is appreciated Thanks, Rajesh rajesh
-
Hello Friends, I am facing some problem in Date Time in c#. I wrote program like this string strdt= "06/19/2006"; //mm/dd/yyyy DateTime dt= Convert.ToDateTime(strdt).ToString("d") ; When I execute this then I get value in dt like "6/19/2006" But, Actually I need value in dt "06/19/2006" in this format. I mean to say Zero with Six. How can I solve this problem? Any help is appreciated Thanks, Rajesh rajesh
DateTime dt = DateTime.Parse(strdt);
Console.WriteLine(dt.ToString("MM/dd/yyyy"));
Try code model generation tools at BoneSoft.com.