Hey everyone,
Basically everything im trying to do is summed up in the subject line. I have a "DatePicker" control on my site, that when a date is selected, is displayed in the textbox as "April 12, 2012" or whatever the subsequent date may be. However, when I save this into my DB in a "Date" field, it saves in the format of "2012-04-12" which is fine with me, I just need to know the function in order to compare the DB value to a value in the DateSelector textbox. This is for a system I am building in case a user wants to "edit" a previously stored record, in case they change the subsequent date.

I have tried using
DateTime.Parse(PlanAdmit).ToString("YYYY-mm-dd")

but get the error of;
Conversion from string "YYYY-00-16" to type 'Date' is not valid.

When the date selected was April, 16 2012

Any help is much appreciated.
Thank you for your time,
NickG

Use MM instead of mm (minutes)

DateTime.Parse(PlanAdmit).ToString("YYYY-MM-dd")

hi Nick ...

Try this..........

   DateTime s = DateTime.Now; //Declare date time variable
   String S_Date = s.ToString("MM/dd/yyyy HH:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture); //Convert to desired format
   System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); //dd/MM/yyyy
   s = DateTime.Parse(sate); //assign back to datetime variable...

   once you have converted date time to this format you can directly insert to database............