zoukankan
html css js c++ java
C#根据当前时间确定日期范围(本周、本月、本季度、本年度)[转]
c#版本:
DateTime dt
=
DateTime.Now;
//
当前时间
DateTime startWeek
=
dt.AddDays(
1
-
Convert.ToInt32(dt.DayOfWeek.ToString(
"
d
"
)));
//
本周周一
DateTime endWeek
=
startWeek.AddDays(
6
);
//
本周周日
DateTime startMonth
=
dt.AddDays(
1
-
dt.Day);
//
本月月初
DateTime endMonth
=
startMonth.AddMonths(
1
).AddDays(
-
1
);
//
本月月末
//
DateTime endMonth = startMonth.AddDays((dt.AddMonths(1) - dt).Days - 1);
//
本月月末
DateTime startQuarter
=
dt.AddMonths(
0
-
(dt.Month
-
1
)
%
3
).AddDays(
1
-
dt.Day);
//
本季度初
DateTime endQuarter
=
startQuarter.AddMonths(
3
).AddDays(
-
1
);
//
本季度末
DateTime startYear
=
new
DateTime(dt.Year,
1
,
1
);
//
本年年初
DateTime endYear
=
new
DateTime(dt.Year,
12
,
31
);
//
本年年末
SQL版本:
select
dateadd
(
day
,
2
-
datepart
(dw,
getdate
()),
getdate
())
[
星期一
]
,
dateadd
(
day
,
8
-
datepart
(dw,
getdate
()),
getdate
())
[
星期日
]
查看全文
相关阅读:
消息中间件选型
Spring MVC中基于注解的 Controller
Servlet线程安全问题
ps -C
getconf LONG_BIT 得到系统的位数
安装memcached服务器和PHP中添加memcache拓展模块
mysql 源码包 有的版本 可能没有 CMakeCache.txt
mysql php nginx 源码包下载地址
使yum保留下载的rpm包
制做RPM包
原文地址:https://www.cnblogs.com/cnaspnet/p/1232427.html
最新文章
Unity3D 相机跟随主角移动
U3D 实现子弹发射效果
Unity3D 5.0简单的射线检测实现跳跃功能
Android 自定义shape圆形按钮
Android dialog 不消失
android:versionCode和android:versionName
Android 大神博客汇集
Android Studio 打包流程
listView 单选实现
Android Studio 使用github
热门文章
getActionBar()空指针异常
Android 避免APP启动闪黑屏的解决办法(Theme和Style)
Android的onCreateOptionsMenu()创建菜单Menu详解
HashMap多线程死循环问题
线程中断
系统架构设计理论与原则
Redis Cluster原理
Controller和RequestMapping
SpringMVC与Struts2配置区别
BeanFactory与FactoryBean
Copyright © 2011-2022 走看看