zoukankan
html css js c++ java
[转] c# 时间操作
一、取某月的最后一天
一、取某月的最后一天
法一、使用算出该月多少天,年
+
月
+
加上多少天即得,举例取今天这个月的最后一天
private
void
GetLastDateForMonth(DateTime DtStart,
out
DateTime DtEnd)
{
int
Dtyear,DtMonth;
DtStart
=
DateTime.Now;
Dtyear
=
DtStart.Year;
DtMonth
=
DtStart.Month;
int
MonthCount
=
DateTime.DaysInMonth(Dtyear,DtMonth);
DtEnd
=
Convert.ToDateTime(Dtyear.ToString()
+
"
-
"
+
DtMonth.ToString()
+
"
-
"
+
MonthCount);
}
法二、取出下月的第一天减去一天便是这个的最后一天
private
void
GetLastDateForMonth(DateTime DtStart,
out
DateTime DtEnd)
{
int
Dtyear,DtMonth;
DtStart
=
DateTime.Now.AddMonths(
1
);
Dtyear
=
DtStart.Year;
DtMonth
=
DtStart.Month;
DtEnd
=
Convert.ToDateTime(Dtyear.ToString()
+
"
-
"
+
DtMonth.ToString()
+
"
-
"
+
"
1
"
).AddDays(
-
1
);
}
法一、使用算出该月多少天,年
+
月
+
加上多少天即得,举例取今天这个月的最后一天
法二、取出下月的第一天减去一天便是这个的最后一天
查看全文
相关阅读:
python之连接oracle数据库
从一副牌中随机抽一张牌
判断一个点是否在圆内
判断每个月有多少天
猜数字游戏
求一元二次方程的2个跟
Servlet细节处理
Servlet
Http协议
Struts2(2)
原文地址:https://www.cnblogs.com/xiang/p/454957.html
最新文章
springboot07-security
springboot06-swagger2 自动化api文档
springboo05-redis
springboot使用jpa+mongodb时,xxxRepository不能Autowired的问题
springboot03-unittest mockmvc单元测试
mysql函数大全
undefined与null的区别
AJAX解析
JSON解析字符串
EL
热门文章
execute、executeQuery和executeUpdate之间的区别
jsp 内置对象---EL
字符集和字符编码(Charset & Encoding)
访问修饰符
Hibernate 缓存机制
JSON解析工具-org.json使用教程
接口相关概念总结
Postman提取返回值
PostMan授权认证使用
测试计划
Copyright © 2011-2022 走看看