>>>>>>Hi,
>>>>>>
>>>>>>I want to send to the SQL Server the following update command:
>>>>>>
>>>>>>
>>>>>>"update MyTable Set DateTimeColumn = " + TTOC(DateTime()) + " where Pk = " + nPk
>>>>>>
>>>>>>
>>>>>>The TTOC() does not seem to do the job as SQL Server returns an error. What would be the right syntax for sending the current Date and Time to update SQL Serrver column?
>>>>>>
>>>>>>TIA.
>>>>>
>>>>>
>>>>>Dmitry,
>>>>>
>>>>>I would try
>>>>>
>>>>>
>>>>>ttoc(DateTime(), 1)
>>>>>
>>>>>
>>>>>Update:
>>>>>
>>>>>You may need to put the value between single quotes
>>>>>
>>>>>
>>>>>
>>>>>[update MyTable Set DateTimeColumn = '] + TTOC(DateTime()) + [' where Pk = ] + nPk
>>>>>
>>>>
>>>>Thank you, Gregory. You are probably right that I was missing single quotes. I will try with quotes.
>>>
>>>i also maint : TTOC(..., 1) to have the yyyymmddhhmmss format
>>
>>Does it really matter what format is the DateTime string since I am relying on SQL Server to set the value into the DateTime column?
>
>
>I found the list of the formats here
http://msdn.microsoft.com/en-us/library/ms187928.aspx>
>
>transf(ttoc(datetime(), 1), '@R ####-##-##T##:##:##')
>
>
>But the best is using parameters - no conversion needed
Thank you for the link. For this particular case I chose to use GetDate() that seems to be the native SQL server function and probably synchronizes the date and time with the SQL Server which I think is a benefit.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham