Insert date and time into MySQL with ColdFusion

后端 未结 3 540
南方客
南方客 2020-12-21 06:55

I am totally lost here.

There is a field of type \"datetime\" in MySQL database. I want to populate it with a datetime generated by ColdFusion program. I found that

3条回答
  •  情歌与酒
    2020-12-21 07:22

    You do not need quotes around date objects, only strings. Removing the quotes should resolve your syntax error:

      INSERT INTO some_table (`date`)
      VALUES ( #myDateTime# )
    

    Though you should get into the habit of using cfqueryparam

      INSERT INTO some_table (`date`)
      VALUES (  )
    

    ... OR if it is a valid/parseable US date string, you could skip the createODBCDate and just use:

      INSERT INTO some_table (`date`)
      VALUES (  )
    

提交回复
热议问题