mysql
한달전 where reg_date >= date_add(now(), interval -1 month)
하루전 where reg_date >= date_add(now(), interval -1 day)
한시간전 where reg_date >= date_add(now(), interval -1 hour)
+이면 후가 되겠죠!
기타 날짜 조건
select date_format(D_time,"%Y-%m-%d") from 테이블명
select date_format(D_time,"%H:%i::%s") from 테이블명
D_time 오늘인거 가져오기
select D_time from 테이블명 where date_format(D_time,"%Y-%m-%d") = current_date;
등록된지 24시간이 안된거 가져오기
select D_time from 테이블명 where D_time > date_sub(now(), interval 1 day);
------------------------------------------------------------------------
example
------------------------------------------------------------------------
최근 3일 이내의 데이터 가져오기
select * from test where Time > date_add('2014-11-22 00:00:00',interval -3 day) order by Time asc
특정한 문자를 포함한 데이터 가져오기
select * from test where Time like '2014-11-19%'
'MySQL' 카테고리의 다른 글
mysql user 생성시 ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value (0) | 2017.09.07 |
---|---|
MySQL 원격 접속 허용 (0) | 2017.09.07 |
SQL UNION 구문 (0) | 2014.12.02 |
MySQL charset encoding (0) | 2014.11.26 |
MySQL 테이블 인코딩 변경하기 (0) | 2014.11.26 |