开发者

What is the correct syntax for SQL Statement using MySQL

开发者 https://www.devze.com 2022-12-13 01:33 出处:网络
In access i used this and its works fine: (tblReservations_Dates.Date) Between #\" & dteBegDate & \"# And #\" & dteEndDate & \"#

In access i used this and its works fine:

(tblReservations_Dates.Date) Between #" & dteBegDate & "# And #" & dteEndDate & "# 

Using MySQL I used this:

(tblReservations_Dates.Date) Between '" & dteBegDate & "' And '" & dteEndDate & "'

However the data is not displayed I was just wonderi开发者_运维问答ng if this is the correct syntax for SQL Statement for comparing dates?


  1. You don't need the brackets around the table.column reference
  2. You need to make sure the query is submitting the start & end values in the proper datattype - date in this case.

Use STR_TO_DATE to safely convert whatever you're providing into a date datatype for MySQL. If you provide the date format, I'd be happy to update my answer with an example.


You need to make certain that the date strings (dteBegDate and dteEndDate) are in the format expected by MySQL, which would be YYYY-MM-DD HH:MM:SS. So, right now would be

2009-11-25 21:45:52

(in Pacific time). Other than that, it should work fine.

0

精彩评论

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