We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how do i assign a datetime value to datetimepicker control

Thread ID:

Created:

Updated:

Platform:

Replies:

1120 Sep 24,2002 08:00 AM UTC Jul 8,2003 01:29 PM UTC WinForms 2
loading
Tags: FAQ
itisme
Asked On September 24, 2002 08:00 AM UTC

hi all, I want to assign a date to a datetimepicker control, I tried the following lines of code dtpPoDate = new DateTimePicker( ); dtpPoDate.Size = new Size( 100, 20 ); dtpPoDate.Location = new Point( 600, 80 ); dtpPoDate.CustomFormat = "dd'/'MM'/'yy"; dtpPoDate.Format = DateTimePickerFormat.Custom; Controls.Add( dtpPoDate ); dtpPoDate.Value = Convert.ToDateTime("01/01/02"); but I'm getting the error message as System.FormatException: Could not determine the order of year, month, and date from m/d/yyyy. at System.DateTimeParse.GetYearMonthDayOrder(String datePattern, DateTimeFormatInfo dtfi) at System.DateTimeParse.GetDayOfNNN(DateTimeResult result, DateTimeRawInfo raw, DateTimeFormatInfo dtfi) at System.DateTimeParse.ProcessTerminaltState(Int32 dps, DateTimeResult result, DateTimeRawInfo raw, DateTimeFormatInfo dtfi) at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider) at System.DateTime.Parse(String s) at System.Convert.ToDateTime(String value) at testdatagrid.GetPoDet() at testdatagrid.OnGotFocus_cmbSuppId(Object Sender, EventArgs e) at System.Windows.Forms.Control.OnGotFocus(EventArgs e) at System.Windows.Forms.Control.WmSetFocus(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ComboBox.WndProc(Message& m) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) could some one help me how to get this out ? regards, lat.

danny liao
Replied On October 29, 2002 07:32 PM UTC

Hi,lat You're using the wrong format. This should work: change: dtpPoDate.CustomFormat = "dd'/'MM'/'yy"; to: dtpPoDate.CustomFormat = "dd/MM/yy"; and dtpPoDate.Value = Convert.ToDateTime("01/01/02"); to: dtpPoDate.Value = Convert.ToDateTime("01/01/2002") > hi all, > > I want to assign a date to a datetimepicker control, > I tried the following lines of code > > dtpPoDate = new DateTimePicker( ); > dtpPoDate.Size = new Size( 100, 20 ); > dtpPoDate.Location = new Point( 600, 80 ); > dtpPoDate.CustomFormat = "dd'/'MM'/'yy"; > dtpPoDate.Format = DateTimePickerFormat.Custom; > Controls.Add( dtpPoDate ); > > dtpPoDate.Value = Convert.ToDateTime("01/01/02"); > > > > but I'm getting the error message as > > System.FormatException: Could not determine the order of year, month, and date from m/d/yyyy. > at System.DateTimeParse.GetYearMonthDayOrder(String datePattern, DateTimeFormatInfo dtfi) > at System.DateTimeParse.GetDayOfNNN(DateTimeResult result, DateTimeRawInfo raw, > > DateTimeFormatInfo dtfi) > at System.DateTimeParse.ProcessTerminaltState(Int32 dps, DateTimeResult result, > > DateTimeRawInfo raw, DateTimeFormatInfo dtfi) > at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) > at System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) > at System.DateTime.Parse(String s, IFormatProvider provider) > at System.DateTime.Parse(String s) > at System.Convert.ToDateTime(String value) > at testdatagrid.GetPoDet() > at testdatagrid.OnGotFocus_cmbSuppId(Object Sender, EventArgs e) > at System.Windows.Forms.Control.OnGotFocus(EventArgs e) > at System.Windows.Forms.Control.WmSetFocus(Message& m) > at System.Windows.Forms.Control.WndProc(Message& m) > at System.Windows.Forms.ComboBox.WndProc(Message& m) > at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) > at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr > > lparam) > > > could some one help me how to get this out ? > > regards, > lat. > >

Administrator [Syncfusion]
Replied On July 8, 2003 01:29 PM UTC

> hi all, > > I want to assign a date to a datetimepicker control, > I tried the following lines of code > > dtpPoDate = new DateTimePicker( ); > dtpPoDate.Size = new Size( 100, 20 ); > dtpPoDate.Location = new Point( 600, 80 ); > dtpPoDate.CustomFormat = "dd'/'MM'/'yy"; > dtpPoDate.Format = DateTimePickerFormat.Custom; > Controls.Add( dtpPoDate ); > > dtpPoDate.Value = Convert.ToDateTime("01/01/02"); > > > > but I'm getting the error message as > > System.FormatException: Could not determine the order of year, month, and date from m/d/yyyy. > at System.DateTimeParse.GetYearMonthDayOrder(String datePattern, DateTimeFormatInfo dtfi) > at System.DateTimeParse.GetDayOfNNN(DateTimeResult result, DateTimeRawInfo raw, > > DateTimeFormatInfo dtfi) > at System.DateTimeParse.ProcessTerminaltState(Int32 dps, DateTimeResult result, > > DateTimeRawInfo raw, DateTimeFormatInfo dtfi) > at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) > at System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) > at System.DateTime.Parse(String s, IFormatProvider provider) > at System.DateTime.Parse(String s) > at System.Convert.ToDateTime(String value) > at testdatagrid.GetPoDet() > at testdatagrid.OnGotFocus_cmbSuppId(Object Sender, EventArgs e) > at System.Windows.Forms.Control.OnGotFocus(EventArgs e) > at System.Windows.Forms.Control.WmSetFocus(Message& m) > at System.Windows.Forms.Control.WndProc(Message& m) > at System.Windows.Forms.ComboBox.WndProc(Message& m) > at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) > at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr > > lparam) > > > could some one help me how to get this out ? > > regards, > lat. > >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;