Java 得到上個月第一天和最後一天

2021-05-28 12:52:53 字數 667 閱讀 9139

public static string lastmonfirstday() else 

if (!(string.valueof(month).length() > 1)) else

if (!(string.valueof(day).length() > 1)) else

string firstday = "" + year + "-" + months + "-01";

string lastmonth = new string[2];

lastmonth[0] = firstday;

return firstday; }

public static string lastmonlastday() else

if (!(string.valueof(month).length() > 1)) else

if (!(string.valueof(day).length() > 1)) else

string lastday = "" + year + "-" + months + "-" + days;

string lastmonth = new string[2];

lastmonth[1] = lastday;

return lastday;

FUNC 返回上個月第一天和最後一天

自定義函式需要獲取上個月的第一天和最後一天,引數為空時,預設為當月的上個月第一天和最後一天,引數不空時,為指定某日期的上個月第一天和最後一天。day 20170101 msgbox 上個月的月初是 firstday n 上個月的月末是 lastday n day 的上個月的月初是 firstday ...

mysql獲取上個月的第一天和最後一天

獲取上個月的最後一天,利用subdate函式和last day函式,可得 select last day subdate 2019 06 01 interval 1 month date獲取上個月的第一天,就是上兩個月的最後一天,再加上一天,select adddate last day subda...

mysql查詢上個月的第一天和最後一天

上個月的第一天 select date sub date sub date format now y m d interval extract day from now 1 day interval 1 month 上個月的最後一天 select date sub date sub date for...