"LAST DAY"의 두 판 사이의 차이

(새 문서: category: Date ;LAST_DAY ;last day of month ;last_of_month *test set :input: 2011-11-11 :output: 2011-11-30 ==Bash== category: Bash <source lang='bash'> INPUT=2011-11-11 LAST...)
 
1번째 줄: 1번째 줄:
[[category: Date]]
[[category: Date]]
==개요==
;LAST_DAY
;LAST_DAY
;last day of month
;last day of month

2014년 9월 3일 (수) 23:35 판

1 개요

LAST_DAY
last day of month
last_of_month
  • test set
input: 2011-11-11
output: 2011-11-30

2 Bash

INPUT=2011-11-11
LAST_DAY=`date +%Y-%m-%d -d "$INPUT +1 month -${INPUT:8:2} days"`
echo $LAST_DAY

3 PHP

$date = "2011-11-11";
$last_day = date('Y-m-d', mktime(0, 0, 0, substr($date,5,2)+1, 0, substr($date,0,4)));
// 2011-11-30
function last_day($day) {
  return date('Y-m-d', mktime(0, 0, 0, substr($day,5,2)+1, 0, substr($day,0,4)));
}

4 SQL

4.1 MySQL

SELECT LAST_DAY( "2011-11-11" );

4.2 Oracle

SELECT LAST_DAY(TO_DATE('2007-12-15', 'yyyy-mm-dd')) FROM DUAL;
-- returns 2007/12/31 00:00:00

SELECT TO_CHAR(LAST_DAY(TO_DATE('2011-02-22', 'yyyy-mm-dd')), 'yyyy-mm-dd') FROM DUAL;
-- returns 2011-02-28

5 See also

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}