Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert a text to a smalldatetime

Status
Not open for further replies.

ndevriendt

Programmer
Jan 8, 2002
74
BE
Hello

I'm working with VB and SQL Server.

I have a table with a field open_time of the type smalldatetime.

In VB I have a data textbox where datamember property contains the value "open_time". De dataformat property
contains the value "Time".

I get an error when I make a change and save my changes with recordset.update. The error tell me that there is a overflow when converting to smalldatetime.

I receive the same error when I save a value with the function Cdate(text) in the field open_time.

Can somebody help me ?

Thanks for your time and answer

Devriendt Nico

 
Nico,

I think its because VB and SQL are set up to use different formats of date. if you try to convert from dd/mm/yyyy to mm/dd/yyyy, it will return a wrong date or an error if the day is greater than 12.
You'll have to find the correct format that's needed by SQL Server. In VB you can create this correct syntax with the format function. ex: Format(Date(), "dd/mm/yyyy hh:mm")

Good luck
Johpje
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top