Chris Johnson

Chris Johnson

  • NA
  • 67
  • 32.2k

DateTimePicker convert error. Cannot convert to Long.

Jun 5 2013 10:24 AM
Hello all,
I have code to convert a datetime to a week number, however I have the following error.

Argument 1: cannot convert from 'System.Windows.Forms.DateTimePicker' to 'long'   


I understand I need to set a parameter on the datetimepicker, however, I have had a long day and just cannot figure it out. Could someone please help me? The code is very simple.

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            var currentCulture = CultureInfo.CurrentCulture;
            var weekNo = currentCulture.Calendar.GetWeekOfYear(
                            new DateTime(dateTimePicker1),
                            currentCulture.DateTimeFormat.CalendarWeekRule,
                            currentCulture.DateTimeFormat.FirstDayOfWeek);
        }

Answers (3)