Reputation: 155
What is the quickest way to convert a DateTime to a int representation of the format yyyyMMdd.
i.e. 01-Jan-2007 --> 20070101 (as in int)?
Upvotes: 10
Views: 19646
Reputation: 354506
int x = date.Year * 10000 + date.Month * 100 + date.Day
Upvotes: 27
Reputation: 564413
int result = int.Parse(myDate.ToString("yyyyMMdd"));
Upvotes: 15