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
())
[
星期日
]
查看全文
相关阅读:
第四届图灵赛A题谷神的赌博游戏
poj1562DFS
数组-03. 冒泡法排序(20)
数组-02. 打印杨辉三角(20)
数组-01. 字符转换(15)
循环-28. 求给定序列前N项和之六(15)
循环-27. 求给定序列前N项和之五(15)
循环-26. 求给定序列前N项和之四(15)
循环-25. 求给定序列前N项和之三(15)
循环-24. 求给定序列前N项和之二(15)
原文地址:https://www.cnblogs.com/cnaspnet/p/1232427.html
最新文章
【Stanford Online】Engineering: Algorithms1 NO.11 Dijkstra's Shortest-path algorithm
【Stanford Online】Engineering: Algorithms1 NO.10 Graph search and connectivity
作业分析,Karger最小割:(python)Engineering: Algorithms1
【Stanford Online】Engineering: Algorithms1 NO.9 Graph and the contraction algorithm
【Stanford Online】Engineering: Algorithms1 NO.5 QuickSort Algorithm
作业分析:(python)Engineering: Algorithms1
【Stanford Online】Engineering: Algorithms1 NO.3 Divide & conquer algorithms
【Stanford Online】Engineering: Algorithms1 NO.1 Introduction
2013 UBC Machine Learning NO.6 Bayesian learning
CS294-112 深度强化学习 秋季学期(伯克利)NO.23 Guest lecture: Mohammad Norouzi (On the role of entropy and relative entropy in RL and the connections to supervised learning)
热门文章
CS294-112 深度强化学习 秋季学期(伯克利)NO.22 Guest lecture: Pieter Abbeel (Deep Learning-to-Learn For Robotic Control)
CS294-112 深度强化学习 秋季学期(伯克利)NO.21 Guest lecture: Aviv Tamar (Combining Reinforcement Learning and Planning)
线段树模板
hdu1873看病要排队
hdu1495非常可乐
POJ3984BFS记录路径
poj2243BFS
hdu2115
hdu2114
那么大奶牛之神
Copyright © 2011-2022 走看看