string BoxCode = "X20171215090101"; DateTime t = DateTime.ParseExact(BoxCode.Substring(1, 14), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture).AddDays(-i);