반응형
strftime()함수는 지정된 형식에 따라 datetime 값 을 형식화하는 데 사용 됩니다
Format Description
| %d | day of the month: 01-31 |
| %f | fractional seconds: SS.SSS |
| %H | hour: 00-24 |
| %j | day of the year: 001-366 |
| %J | Julian day number |
| %m | month: 01-12 |
| %M | minute: 00-59 |
| %s | seconds since 1970-01-01 |
| %S | seconds: 00-59 |
| %w | day of week 0-6 with Sunday==0 |
| %W | week of the year: 00-53 |
| %Y | year: 0000-9999 |
| %% | % |
사용예
SELECT strftime('%s','now'); -- 현재 Unix 타임 스탬프
SELECT strftime('%d','2018-10-11'); -- 일 출력
=> 11
SELECT strftime('%m','2018-10-11'); -- 월 출력
=> 10
SELECT strftime('%Y','2018-10-11'); -- 년 출력
=> 2018
SELECT strftime('%H','10:20:30'); -- 시간 출력
=> 10
SELECT strftime('%M','10:20:30'); 분 출력
=> 20
SELECT strftime('%S','10:20:30'); 초 출력
=> 30
반응형
댓글