开发者

Now() In ODBC SQL Query?

开发者 https://www.devze.com 2022-12-31 05:59 出处:网络
I\'m trying to update a database field to the current time, but can\'t pass \"now()\".I get the following error:

I'm trying to update a database field to the current time, but can't pass "now()". I get the following error:

'`now`' is not a recognized built-in function name.

The method I'm using to query the database is as follows:

Public Sub main()

    Dim cnn As ADODB.Connection
    Dim rst As ADODB.Recordset

    Set cnn = New ADODB.Connection
    Set rst = New ADODB.Recordset

    cnn.Open "ConnectionName"
    rst.ActiveConnection 开发者_运维百科= cnn
    rst.CursorLocation = adUseServer

    rst.Source = "Update Table ..."
    rst.Open

    Set rst = Nothing
    Set cnn = Nothing
End Sub


Now() is a VBA function. What you want to do is use the equivalent SQL function, but that depends on the database that you're connecting to.

If it's SQL Server you're connecting to, use GETDATE() (for local times) or GETUTCDATE() (for UTC times).


Try getdate() function or CURRENT_TIMESTAMP

0

精彩评论

暂无评论...
验证码 换一张
取 消