Wednesday, December 29, 2010

CrmDateTime conversion to DateTime

1.Convert.ToDateTime(crmdatetime.Value)
2.DateTime.Parse(crmdatetime.Value)

For more information on the CrmDateTime, look in the SDK:

Check here

Labels: , , , , , , ,

Wednesday, September 30, 2009

Month Name from Month Number

Getting Month Name from the Month Number is quite easy by extending DateTime properties in .net.

For Example, if you are having a month number, say 2, which you need to convert it into corresponding Month Name(February)




string strMonth = "2";

DateTime date = new DateTime(1, strMonth, 1);

string strMonthName = date.ToString("MMM");



This will return you the month name "Feb" ,but only first three characters.

If you need the month name in full, slightly modify the above syntax



string strMonth = "2";

DateTime date = new DateTime(1, strMonth, 1);

string strMonthName = date.ToString("MMMM"); // Four Characters will give you the full month name.



Happy Coding..

Labels: , , , , , , ,