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
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,
Did you mean "April 16, 2012"?
Watch the case on your format. It's "yyyy" not "YYYY" and "MM" not "mm".
Console.WriteLine(DateTime.Parse("April 16, 2012").ToString("yyyy-MM-dd"));
This topic is now archived. It is frozen and cannot be changed in any way.