根据年、月、周、求本月的起始日和结束日!解决思路
发布时间:2011-06-24 19:02:10 文章来源:www.iduyao.cn 采编人员:星星草
根据年、月、周、求本月的起始日和结束日!
根据年、月、周、求本月的起始日和结束日!
根据年、月、周、求本月的起始日和结束日!
根据年、月、周、求本月的起始日和结束日!
------解决方案--------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(GetStartDate(2011, 8, 2));
Console.WriteLine(GetEndDate(2011, 8, 2));
}
static DateTime GetStartDate(int year, int month, int week)
{
if (week < 1) return default(DateTime);
if (week == 1)
return new DateTime(year, month, 1);
else
return GetEndDate(year, month, week - 1).AddDays(1);
}
static DateTime GetEndDate(int year, int month, int week)
{
if (week < 1) return default(DateTime);
DateTime dt = new DateTime(year, month, 1);
if (week == 1)
return new DateTime(year, month, 1).AddDays(6 - (int)(new DateTime(year, month, 1)).DayOfWeek);
else
return GetEndDate(year, month, week - 1).AddDays(7);
}
}
}
2011-8-7 0:00:00
2011-8-13 0:00:00
Press any key to continue . . .
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
关于FileUpload.Postedload的用法
大侠们,小弟写了个文件上传的程序,可是运行总是报错,错误提示如下
非静态字段、方法或属性“Sys...
-
我这样的技术找工作真的很难吗?【比北大青鸟出来的和应届毕业生都不如】
我本科的,只做过一个网站www_gzfesco_com_cn-------》这...
-
Visual J# 断点调试和vc有什么区别?
如题
------解决方案--------------------
帮顶,学习。
------解决方案--------------------...
-
j# form中 放了pictureBox1控件,label1控件放在pictureBox1上面,如何能把label1背景设置为透明呢
请教各位了。
------解决方案-...
-
问一下关于silverlight 的问题 大家别扔我啊 就是有点搞不清楚!
一直觉的silverlight 做出来的东西很炫
也知道它是微软开发的...
-
根据年、月、周、求本月的起始日和结束日!
根据年、月、周、求本月的起始日和结束日!
根据年、月、周、求本月的起始日和结束日!
...
-
TextBox Readonly 后,前台赋值,后台无法取得资料
请教如何处理,最好不要用隐藏控件解决,在线等回复
------解决方案----------------...
-
javascript
$(document).ready(function() {
$("#CheckAll").click(function() {
if ($(this).attr("checked") ==...
-
winform DataGridView根据光标位置设置所在行的背景颜色
如题。。。
------解决方案--------------------
C# code
private voi...
-
如何防止多个title出现
是这样的,为了实现SEO,我用的母板,下面用了一个content但是运行时页面出现了两对<title>标签,我只想显示conte...