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

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 하나는 보이지 않습니다)
1번째 줄: 1번째 줄:
[[category: Date]]
[[category: 날짜]]


==개요==
==개요==
10번째 줄: 10번째 줄:
==Bash==
==Bash==
[[category: Bash]]
[[category: Bash]]
<source lang='bash'>
<syntaxhighlight lang='bash'>
INPUT=2011-11-11
INPUT=2011-11-11
OUTPUT="${INPUT:0:7}-01"
OUTPUT="${INPUT:0:7}-01"
echo $OUTPUT
echo $OUTPUT
</source>
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='php'>
<syntaxhighlight lang='php'>
function first_of_month($day) {
function first_of_month($day) {
   return substr($day, 0, 7).'-01';
   return substr($day, 0, 7).'-01';
}
}
</source>
</syntaxhighlight>


==SQL==
==SQL==
28번째 줄: 28번째 줄:
===MySQL===
===MySQL===
[[category: MySQL]]
[[category: MySQL]]
<source lang='sql'>
<syntaxhighlight lang='sql'>
SELECT CONCAT(SUBSTR("2011-11-11",1,8),"01");
SELECT CONCAT(SUBSTR("2011-11-11",1,8),"01");
-- 2011-11-01
-- 2011-11-01
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[LAST_DAY]]
*[[LAST_DAY]]
*[[first_of_this_month]]
*[[first_of_this_month]]

2020년 11월 2일 (월) 02:34 기준 최신판


1 개요[ | ]

FIRST_DAY
first day of month
first_of_month
  • test set
"2011-11-11" → "2011-11-01"

2 Bash[ | ]

INPUT=2011-11-11
OUTPUT="${INPUT:0:7}-01"
echo $OUTPUT

3 PHP[ | ]

function first_of_month($day) {
  return substr($day, 0, 7).'-01';
}

4 SQL[ | ]

4.1 MySQL[ | ]

SELECT CONCAT(SUBSTR("2011-11-11",1,8),"01");
-- 2011-11-01

5 같이 보기[ | ]

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