By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

convert varchar field in sql database into datetime value while retrieving to display

P: 1
Expand|Select|Wrap|Line Numbers
  1. DateTimePicker1.Text = reader(Convert.ToDateTime("PURCHASED_DATE"))
this is my code the PURCHASED_DATE field is varchar(50) datatype but when retriving it should be in datetime format

the error is "the string was not recognised as a valid datetime.there is a unknown word starting at index 0
please help me to over come the problem
Feb 21 '13 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 10K+
P: 12,383
You would need to post the values that it says is not a valid date time value.
Feb 21 '13 #2

P: 94
Your code is converting the string "PURCHASED_DATE" instead of the reader value. Try this:
Expand|Select|Wrap|Line Numbers
  1.   Convert.ToDateTime(reader("PURCHASED_DATE"))
Feb 23 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.