Insert SQL command with Datetime in MS-Access

后端 未结 1 948
余生分开走
余生分开走 2020-12-06 17:02

I am trying the following query in MS-Access 2007, but it fails on the time field.

INSERT INTO LOG (
    EMPLOYEECODE, STATUSID, LOCATIONID, TIME, DURATION,
         


        
相关标签:
1条回答
  • 2020-12-06 17:56

    Date & Time input in access use #, since access can't do auto conversion from char/text into date or time in SQL Query (or access call it query), and you better use international standard for inputting date time which was YYYY-MM-DD HH:NN:SS (4-digit year, 2-digit month, 2-digit day, 2-digit hour, 2-digit minute, 2-digit second)

    so for 4/21/2009 2:25:53 PM use #2009-04-21 14:25:53#

    or if it still fail, you can use #'2009-04-21 14:25:53'#

    Edit: Above might be working if you enable ANSI 92 or using ADO/OLEDB as database interface, thanks David for pointing out

    I suggest you use YYYY-MM-DD HH:NN:SS format and try it with single quotes (') before use # like i said above

    0 讨论(0)
提交回复
热议问题