[MySQL] 날짜 더하기와 빼기 > db

본문 바로가기

db

[MySQL] 날짜 더하기와 빼기

작성일 13-01-02 10:59

페이지 정보

작성자서방님 조회 287회 댓글 0건

본문

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);

댓글목록

등록된 댓글이 없습니다.

게시물 검색
Copyright © 서방님.kr All rights reserved.
PC 버전으로 보기