1.SQL数据库中:
select DATEDIFF(day, getdate(), dateadd(month,1,getdate()))
主要原理是用下个月份和这个月份的差来计算当前月份有几天.
可以扩展一下,就能获得某个月有几天啦.
2.C#中:
public static int DaysInMonth ( int year, int month )
返回指定年和月中的天数。
命名空间:System
程序集:mscorlib(在 mscorlib.dll 中)
参数
-
year
-
年份。
-
month
-
月份(介于 1 到 12 之间的一个数字)。
返回值
指定 year 中 month 的天数。 例如,如果 month 等于 2(表示二月),则返回值为 28 或 29,具体取决于 year 是否为闰年。