| re: Correct datetime syntax for MSSQL?
On Sat, 15 Oct 2005 03:18:58 GMT, "Ian Hinson"
<pparagon@bigpond.net.au> wrote:
In T-SQL, dates are wrapped in single quotes.
-Tom.
[color=blue]
>Hi,
>
>Sometimes I find it handy to construct an sql string for action queries, and
>then run it directly against the database and/or connection instead of using
>Recordsets for simple updates.
>eg. This query works in MS Access (using dbs.Execute):
>
>UPDATE Customer SET LastContact = #2/5/2005 13:15:00#
>WHERE Customer.CustomerID = 101;
>
>I'm now upsizing an app to SQL server, using ADP front-end.
>Date/Time fields were converted (by the wizard) to MSSQL datetime fields.
>
>I'm finding that Date/Time literal expressions (formatted as #m/d/yyyy
>hh:nn:ss#) are not acceptible to MSSQL? Running above using cnn.Execute
>gives SQL syntax error at the # symbol.
>
>If so, how do you write a literal date in an SQL query for executing against
>SQL server?
>
>Thanks,
>Ian.
>[/color] |