In my database I have a field date of type **varchar** where the date is stored in the following format **yyyyMMddhhmm**, with no spaces or other characters separating them.

Now I need to compare this date with a C# **DateTime**, therefore I need to convert the string into **DateTime**. The most logical way that I can think of is to extract from the variable `date` the sub-string related to year, month and day and create a new **DateTime** object:

```
var year = Convert.ToInt32(date.Substring(0, 4));

var month = Convert.ToInt32(date.Substring(4, 2));

var day = Convert.ToInt32(date.Substring(6, 2));

DateTime dateToCompare = new DateTime(year, month, day);

```

Is there any available C# method that allows me to perform this conversion without writing all this code?