Changing a Date Time Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Changing a Date Time Value

I have a form with a date time picker or it and a button. When the button
is pressed it passes the date/time into a stored procedure that queries an
SQL database. Because the date time format is different I am receiving an
error.

I want the date format to be “dd-MMM-YYYY HH:MM:SS†e.g. “31-Dec-2006
23:59:59â€

I think I need to use the CDate function but I cant seem to get it to work.
Please help!
 
BH,

I can start a long message. However mostly is the only problem that the Text
property is taken from the DateTime picker, while it has to be the Value
property (than it is already in the datetime format).

If this not help, than reply, althouhg I hope it helps of course.

Cor
 
Hi bh,

If you have a DateTime object, you can always format the output any way
you want.

DateTime dt = new DateTime(2006, 12, 31, 23, 59, 59);
MessageBox.Show(dt.ToString("dd-MMM-yyyy HH:mm:ss"));

(Note, small y m s for year, minutes, seconds)
 
Back
Top