Convert Date to Numeric in Dot Net

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under Visual Studio category on | Points: 40 | Views : 334
Here is the code,
public int DateToInt32(DateTime dtCurrent)
{
int ReturnValue;
System.Text.StringBuilder sb = new System.Text.StringBuilder();

sb.Append(dtCurrent.Year.ToString("D4"));
sb.Append(dtCurrent.Month.ToString("D2"));
sb.Append(dtCurrent.Day.ToString("D2"));

ReturnValue = Convert.ToInt32(sb.ToString());

return ReturnValue;
}
Response.Write(DateToInt32(DateTime.Now));

Output:-
20150524

Comments or Responses

Login to post response