between
키워드는 문자열이 아닌 날짜 값에서 작동합니다. 내가 열이 타임 스탬프로 정의되기 때문에 (MySQL의) 날짜 record_ts을 변환해야
<?php
$jan = '2014-01';
$feb = '2014-02';
$sql = "select record_ts from table where date(record_ts)
between str_to_date('$jan', '%Y-%m')
and str_to_date('$feb', '%Y-%m');
";
?>
공지 사항, 나는 또한 날짜 문자열을 변환해야합니다.
. . .
Carl Maskham, 귀하의 의견은 최신 버전의 MySQL에서 유효 할 수 있습니다.
mysql> select record_ts from table where date(record_ts)
between '2014-01'
and '2014-02' ;
Empty set, 2 warnings (0.01 sec)
mysql> select record_ts from table where date(record_ts)
between str_to_date('2014-01', '%Y-%m')
and str_to_date('2014-02', '%Y-%m');
(...)
1119 rows in set (0.01 sec)
$ mysql --version
mysql Ver 14.14 Distrib 5.1.70, for pc-linux-gnu (x86_64) using readline 5.1
'date (transdate) = CURDATE()'?? –
도 참조하십시오. http://stackoverflow.com/a/16372608/689579 – Sean
@ 단일 시점의 대각선?!,!!?!? –