=====================
表名为:tableName
时间字段名为:theDate
=====================
datePart函数

日期部分 缩写
year yy, yyyy
quarter qq, q
month mm, m
dayofyear dy, y
day dd, d
week wk, ww
weekday dw
Hour hh
minute mi, n
second ss, s
millisecond ms

查询本日的记录
select * from tableName where DATEPART(dd, theDate) = DATEPART(dd, GETDATE()) and DATEPART(mm, theDate) = DATEPART(mm, GETDATE()) and DATEPART(yy, theDate) = DATEPART(yy, GETDATE())

查询本周的记录
select * from tableName where DATEPART(wk, theDate) = DATEPART(wk, GETDATE()) and DATEPART(yy, theDate) = DATEPART(yy, GETDATE())

查询本月的记录
select * from tableName where DATEPART(mm, theDate) = DATEPART(mm, GETDATE()) and DATEPART(yy, theDate) = DATEPART(yy, GETDATE())

查询本季的记录
select * from tableName where DATEPART(qq, theDate) = DATEPART(qq, GETDATE()) and DATEPART(yy, theDate) = DATEPART(yy, GETDATE())

查询本年的记录
select * from tableName where DATEPART(yy, theDate) = DATEPART(yy, GETDATE())


其中:GETDATE()是获得系统时间的函数。 

--------------------------------------------------------------------------------------------------------------------------------------------------
datediff函数

日期部分 缩写
year yy, yyyy
quarter qq, q
Month mm, m
dayofyear dy, y
Day dd, d
Week wk, ww
Hour hh
minute mi, n
second ss, s
millisecond ms

查询本日的记录
select count(*) from tableName where (DATEDIFF(dd, theDate, GETDATE()) = 0)
查询本周的记录
select count(*) from tableName where (DATEDIFF(wk, theDate, GETDATE()) = 0)
查询本月的记录
select count(*) from tableName where (DATEDIFF(mm, theDate, GETDATE()) = 0)
查询本季的记录
select count(*) from tableName where (DATEDIFF(qq, theDate, GETDATE()) = 0)
查询本年的记录
select count(*) from tableName where (DATEDIFF(yy, theDate, GETDATE()) = 0)

原始文章:http://blog.csdn.net/coolwzjcool/archive/2007/08/25/1758470.aspx

posted @ 2008-06-24 15:44 SitHere 阅读(38) | 评论 (0)编辑
在类库内部可以通过 System.Web.HttpContext.Current 来判断当前代码是运行于 ASP.net 工程还是 WinForm/Console。

1using System.Web;
2
3
4
5if (System.Web.HttpContext.Current != null)
6  Debug.WriteLine("运行于 ASP.net ");
7else
8  Debug.WriteLine("运行于 WinForm/Console ");

作者: yuhen
posted @ 2008-05-11 18:06 SitHere 阅读(7) | 评论 (0)编辑
     摘要: "怎样保护我程序中的 DLL 不被别人盗用……"当我看到这个问题的第一反应不是保护,而是满脑子的 IL 反编译代码。说实话,无论你用什么方法,都不能避免被有心人 "破解"。混淆也好,加壳也罢,不过是让别人多费些功夫而已。当然,这会大大缩减 "有心人" 的范围。要保护自己的 DLL 不被别人盗用,最好的办法是把它合并到 Entry EXE 中,然后无论是 public 还是 ... 阅读全文
posted @ 2008-05-11 17:59 SitHere 阅读(49) | 评论 (0)编辑