I am using VB 2008 and have a datetime picker. I wam trying to use this value in an INSERT command to load in to a table but I just can't get it to work. I debug it out which shows something along the lines of "24/03/2010" but it just won't accept it. However, if I create a string variable e.g. strDate = "24/03/2010". it works. I am obviously doing something wrong in the conversion. Don't suppose someone could tell me what.

Thanks

check it in table structure, the datetime data s string data type or datetime

Thanks for the reply Renukavani.

Managed to sort it by using the format command. I didn't realise you had to insert it using the format yyyy-mm-dd.

Hi,

I am facing the same issue.Please help me how u had solved it.
I am using VS 2008,windows form ,SQL server2008 express :

"INSERT bill_book (PostingDate) VALUES ( '" & Dtp_bill.Text & " ' )"

in sql data type for PostingDate is "Date"

The format that SQL server uses to store date is yyyy-mm-dd
When taking the date as input make sure you take it in this format, u can change the format from the properties window while putting the date time picker, as well as manually from code.
If you are inputting the date through keyboard, make sure u input it in the above format.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.