DateTime Problem
-
Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit
Hi, Please use the below:
DateTime dt = DateTime.Now;
string strDate = dt.ToString("dd-MMMM-yyyy");Regards, Jamil
-
Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit
-
Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit
I assume you want to display 5/13/2010 as 13-May-2010 and not 08-May-2010. Its very easy to do it. If you are displaying the date in a label then you are probably assigning the date value to the text property like this
Label1.Text = DateTimeValue.ToString();
. Now to apply formatting in this case just pass the format string as parameter to the ToString() function like thisLabel1.Text = DateTimeValue.ToString("dd-MMM-yyyy");
You could also use thisString.Format("{0:dd-MMM-yyyy}", DateTimeValue.ToString());
NOTE - Month should be specified as "MMM" and not "mmm". For more format strings refer this page - String Format for DateTime [C#][^] -
Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit
-
Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit
Hi, use following while selecting datetype column from databse.
select replace(convert(varchar,getdate(),106),' ','-')
Thanks, Arindam D Tewary