Select data between two dates?

后端 未结 5 407
灰色年华
灰色年华 2020-12-06 08:46

I\'m using a database to store logs, with a column \"date\" which holds the date it was inserted. The format of the date is \"MM/DD/YY\". Please can anyone suggest how I wou

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 09:06

    The answer to your question depends on the data type that is used to store the date field in the logs table.

    SQL (MySQL in your case) is fully capable of comparing dates. Usually, the BETWEEN .. AND .. operator is used but that will not work correctly if the type of date is CHAR (or VARCHAR) - in which case you will need to cast the date field to a DATETIME before comparing.

提交回复
热议问题