如果我正确地阅读你的问题,你会想要在1月31日和2月1日返回"2",因为它跨越1月和2月,即使它们只相隔1天.
你可以解决(伪代码):
monthno1 = (date1_year * 12) + date1_month;
monthno2 = (date2_year * 12) + date2_month;
return (monthno2 - monthno1) + 1;
Run Code Online (Sandbox Code Playgroud)
这假设第二个日期是更晚的日期.
归档时间: |
|
查看次数: |
2997 次 |
最近记录: |