Welcome! Log In Create A New Profile

Advanced

MSSQL - date and time

Posted by Arie 
Arie
MSSQL - date and time
December 24, 2008 10:35AM
Hi, i want to update a datetime-field in a mssql database.

If I update fields directly, I can just use
myTable.myField = DateSys+TimeSys
HModify(myTable)

To speed things up, when updating many records, I want to use HExecuteQuery().
I made a simple update-query and use a parameter for the field I want to update.
myQuery.Param1 = DateSys+TimeSys
HExecuteQeury(myQuery)

This will give me an error!! "Conversion failed when converting datetime from character string".
Do i need pre-format the query-parameter?

I'm using WD12 and OLEDB.

Arie
kevinw
Re: MSSQL - date and time
December 29, 2008 02:04PM
A safe format string to pass to SQL Server to populate a datetime field is:

'YYYY-MM-DDTHH:MMconfused smileyS'

Note the "T" between the date and time.

Kevin
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: