728x90

https://school.programmers.co.kr/learn/courses/30/lessons/131120

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

 

 

풀이)

SELECT member_id, member_name, gender, date_format(date_of_birth, "%Y-%m-%d") as date_of_birth
from member_profile
where gender = "W" and month(date_of_birth)="03" and tlno is not null
order by member_id;

월을 추출할 때 month()를 사용할 수 있다!

년은 year, 일은 day를 사용하면 된다.

 

그 외에도 hour, minute,,, 등등 다 있다!

신기한 sql의 세계...

 

 

 

참고한 블로그

https://gent.tistory.com/440

 

[MSSQL] 년, 월, 일 추출 방법 (YEAR, MONTH, DAY)

SQL Server에서 날짜 데이터의 년, 월, 일을 추출할 때 사용하는 기본적인 함수는 YEAR, MONTH, DAY이며, 정수로 결과를 반환한다. 앞의 세 가지 함수 외에도 DATENAME, DATEPART라는 함수도 있는데 DATENAME 함

gent.tistory.com

 

728x90

+ Recent posts