vic*_*sys 6 mysql sql database
如何通过提供月份和年份作为输入来获取 MySQL 中月份的最后一天。
Similar example, To get last day of the month by date as input
Eg: SELECT LAST_DAY(?) as lastDate
Format:
Input month and year: '07/2015'
Output Result: day /*Eg: 30,31*/
Run Code Online (Sandbox Code Playgroud)
我已经尝试过日期格式,
SELECT LAST_DAY(DATE_FORMAT('09/2015','%m/%Y')) as lastDate但它不起作用
您只需要将您的值转换为日期。这是一种方法:
select last_day(date(concat_ws('-', year, month, 1)))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8648 次 |
| 最近记录: |