//
以下的毫秒都採用最大997,而不是999 因為sql server的精度為3毫秒
//本月的天數
intdaysinmonth
=datetime.daysinmonth(datetime.now.year, datetime.now.month);
//本年的天數 是否是閏年
intdaysinyear
=datetime.isleapyear(datetime.now.year)
?366
: 365;//
本月第一天
datetime firstdayinmonth
=new
datetime(datetime.now.year, datetime.now.month, 1);
//本月的最後一天 本月1號加乙個月得下月1號,再剪掉一天就是本月最後一天
datetime lastdayinmonth
=new
datetime(datetime.now.year, datetime.now.month,
1).addmonths(
1).adddays(-1
);//
本月最後一天的午夜
datetime lastdayinmonth2
=new
datetime(datetime.now.year, datetime.now.month,
1).addmonths(
1).addmilliseconds(-3
);//
本年第一天
datetime firstdayinyear
=new
datetime(datetime.now.year, 1,
1);//本年最後一天
datetime lastdayinyear
=new
datetime(datetime.now.year,
12,
31);
//本年最後一天的午夜
datetime lastdayinyear2
=new
datetime(datetime.now.year,
12,
31,
23,
59,
59,
997);
//得到星期幾 星期天為7
intdayofweek
=convert.toint32(datetime.now.dayofweek)
<1?
7: convert.toint32(datetime.now.dayofweek);
//本周一
datetime monday
=new
datetime(datetime.now.year,datetime.now.month,datetime.now.day).adddays(1-
dayofweek);
//本週 星期天
datetime sunday
=monday.adddays(6);
//本週 星期天的午夜
datetime sunday2
=monday.adddays(
7).addmilliseconds(-3
);//
本季度第一天
datetime firsydayinquarter
=new
datetime(datetime.now.year, datetime.now.month
-(datetime.now.month -1
) %3,
1);//本季度最後一天
datetime lastdayinquarter
=firsydayinquarter.addmonths(
3).adddays(-1
);//
本季度最後一天的午夜
datetime lastdayinquarter2
=firsydayinquarter.addmonths(
3).addmilliseconds(-3
); -----sql------ --
本月的天數
select
day
(dateadd
(day
,-1,
dateadd
(month
,1,convert
(char
(8),
getdate
(),120)+'
01')))--
本年的天數
select
datediff
(day
,datename
(year
,getdate
())+
'-01-01',
datename
(year
,getdate
())+
'-12-31')
+1--
本月第一天
select
convert
(char
(8),
getdate
(),120)+'
01'--本月最後一天
select
dateadd
(day
,-1,
dateadd
(month
,1,convert
(char
(8),
getdate
(),120)+'
01'))--
本月最後一天午夜
select
dateadd
(ms,
-3,dateadd
(month
,1,convert
(char
(8),
getdate
(),120)+'
01'))--
本年第一天
select
convert
(char
(5),
getdate
(),120)+'
01-01'--
本年最後一天
select
convert
(char
(5),
getdate
(),120)+'
12-31'--
本年最後一天午夜
select
convert
(char
(5),
getdate
(),120)+'
12-31 23:59:59:997'--
本周一select
dateadd
(week,
datediff
(week,0,
getdate
()),0)
--本週 星期天
select
dateadd
(day
,-1,
dateadd
(week,
datediff
(week,0,
getdate
())+1,0))
--本週星期天的午夜
select
dateadd
(ms,
-3,dateadd
(week,
datediff
(week,0,
getdate
())+1,0))
--本季度第一天
select
dateadd
(quarter,
datediff
(quarter,0,
getdate
()),0)
--本季度最後一天
select
dateadd
(day
,-1,
dateadd
(quarter,
datediff
(quarter,0,
getdate
())+1,0))
--本季度最後一天的午夜
select
dateadd
(ms,
-3,dateadd
(quarter,
datediff
(quarter,0,
getdate
())+1,0))
字元常用處理
字串.charcodeat 字串索引 可以把字串的單個字元,轉變成字元編碼 string.fromcharcode 字元編碼 可以把乙個或多個字元編碼 轉變成字串。str cc愛tt charcodeat 能把字串轉換為字元編碼 console.log str.charcodeat 0 數字代表字串...
虛擬鍵盤常用處理
1.1 完成輸入後關閉鍵盤 比方說,輸入 name後要實現鍵盤的 done,就要呼叫下面的函式 ibaction textfielddoneediting id sender 與此同時,必須將兩個 textfield連線到這個函式,並且使用的是 did end on exit。1.2觸控背景關閉鍵盤...
MySQL常用處理方法
1.replace into replace into t id,update time values 1,now 或 replace into t id,update time select 1,now replace into 跟 insert 功能類似,不同點在於 replace into 首...