Jamie said:
I use a string (in ISO 8601 format of course) explicitly CAST as
DATETIME, avoiding the proprietary CONVERT as much as possible (but
often cannot be avoided when scrubbing data as in the OP's case) e.g.
SELECT CAST('2006-10-09T10:57:17.887' AS DATETIME)
You have to be careful with language issues in SQL Server: most
datetime formats should be considered unsafe. See:
http://www.karaszi.com/sqlserver/info_datetime.asp
The closest equivalent to the above in Access/Jet would be:
SELECT CDATE('2006-10-09 10:57:18')
but I tend to rely on Jet's DATETIME literal prefix/suffix character
e.g.
SELECT #2006-10-09 10:57:18#
Jamie.
I appreciate your comments Jamie. My problem is that your answer to
this question creates new questions for me to ponder. I want to avoid
specifying explicitly the base date used by the SQL implementation
whenever possible. I like the ISO idea. American dates seem wrong in
going from month to day to year -- definitely desultory and
non-intuitive. Most American users do not want to see the ISO format,
but they don't get to see what date format I use in queries. Perhaps
part of the solution for me is to write some user-defined functions in
Access that allow the SQL to look more like T-SQL. The ideal situation
is to write Access queries that involve the minimum number of changes
when converting to T-SQL. I realize that using Access as a front end
for SQL Server, if I desire, allows me to continue using an
Access-specific SQL style. The SQL used in Access has been great for
introducing me to SQL and relational database design concepts; it's just
too bad that Microsoft's great interest in standards didn't happen
sooner. My programming style has been to seek methods that are
universal and robust. The ISO date format, while not universal, is at
least international

. These issues will require more time for me to
come up with a plan that minimizes the differences. Also, there is no
guarantee that the two versions of SQL will converge to standards or
even converge to each other.
James A. Fortune
(e-mail address removed)
Access Tip:
Instead of setting text field sizes to 255 and letting Access adjust its
own file size to the amount of storage used, get used to specifying
definite text field sizes and enforcing those limits on forms. That
way, if the data is converted to SQL Server, which reserves 255
characters if 255 is specified, you don't waste lots of storage on text
fields. Skip that idea if users get irate when text field size limits
are encountered

.