1 개요[ | ]
- FIRST_DAY
- first day of month
- first_of_month
- test set
- "2011-11-11" → "2011-11-01"
2 Bash[ | ]
Bash
Copy
INPUT=2011-11-11
OUTPUT="${INPUT:0:7}-01"
echo $OUTPUT
3 PHP[ | ]
PHP
Copy
function first_of_month($day) {
return substr($day, 0, 7).'-01';
}
4 SQL[ | ]
4.1 MySQL[ | ]
sql
Copy
SELECT CONCAT(SUBSTR("2011-11-11",1,8),"01");
-- 2011-11-01