473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
2 1472
Rabbit
12,516 Expert Mod 8TB
You would need to post the values that it says is not a valid date time value.
Feb 21 '13 #2
Mikkeee
94 64KB
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"))
  2.  
Feb 23 '13 #3

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

Similar topics

9
by: news.microsoft.com | last post by:
Hello, I have DateTime property. How can I set this value to null?
1
by: ABC | last post by:
How to convert a date string to datetime value with custom date format? e.g. Date String Date Format Result (DateTime value) "05/07/2004" "MM/dd/yyyy" May 7, 2004 "01062005" ...
1
by: suslikovich | last post by:
Hi all, I am getting this error when insert values from one table to another in the first table the values are varchar (10). In the second they are datetime. The format of the data is mm/dd/yyyy...
1
by: Woodies_46 | last post by:
Ok i know this is simple but i just don't know the syntax. What I have is a bunch of values and i want to be able to display them as money values with a $ in front. eg. 16000000 1000 160000
4
by: tshad | last post by:
Is there any difference between convert.ToDateTime and System.DateTime.Parse? I am using them both and they seem the same. Is one better to use than another? Thanks, Tom
4
by: kanpeter | last post by:
Hi, How can I check if all bytes in a varchar field is all numeric using SQL ? -- peter
4
by: Arpan | last post by:
A SQL Server 2005 DB table has 4 columns namely "ID" (IDENTITY int column), "FirstName" (varchar(50)), "LastName" (varchar(50)) & "DOB" (datetime). Now when I am trying to add a new row using the...
0
by: Larrys | last post by:
I am fetching a VARCHAR field in a cursor. The VARCHAR field ins defined as 'not null with default'. When I am fetching a row where the VARCHAR field does not have a value, the value of the working...
5
by: ITCraze | last post by:
Please Guys help me out , as I need the solution of this problem very fast.Please help me. My table contains a varchar field which contains time like : 04:09PM Now the problem is that I have...
2
by: raam | last post by:
create proc getproviders as begin select ProviderType,ProviderTypeId,ProviderName,City,State,Country, ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.