string dateFrom = perFromDate.Value.ToString("MMM-yyyy"); string dateTo = perToDate.Value.ToString("MMM-yyyy"); TimeSpan range = DateTime.Parse(dateTo).Subtract(DateTime.Parse(dateFrom)); int newRange = range.Days; if (newRange > 365) { MessageBox.Show("Date is out of range.", "Validation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
private void Form1_Load(object sender, EventArgs e) { dateTimePicker1.Format = DateTimePickerFormat.Custom; dateTimePicker1.CustomFormat = "yyyy-MM"; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)