썩구노트
MySQL 날짜 더하기와 빼기 본문
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);
'DB' 카테고리의 다른 글
where절에 if문처럼 and조건 사용하기 (0) | 2016.10.28 |
---|---|
MySQL 함수를 활용한 날짜비교 쿼리문 작성하기 [출처] MySQL 함수를 활용한 날짜비교 쿼리문 작성하기|작성자 네오 에이치 (0) | 2016.10.28 |
[MySQL] COUNT 데이터 갯수 세기 - Distinct 중복제거 (0) | 2016.10.27 |
[Mysql] DATETIME과 TIMESTAMP (0) | 2016.10.27 |
[MYSQL] 날짜와 시간 타입 (column type) (0) | 2016.10.27 |