1.Sql中getDate()在查询语句中的用法
select * FROM V_MANAGERPLAN where (SEAT_ID in (45,46)) and (GETDATE() between BeginTime and EndTime) order by Shift_sortid,seatSort
2.日期加星期(示例:2017-12-22 星期五)
<span class="sWeek"> <%=DateTime.Now.ToString("yyyy-MM-dd") %> <%=System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek)%></span>
3.定时器间隔多少毫秒执行
var time1=$.trim($("#sUserName1").html() == "暂无排班信息")==true?30000:1800000; setInterval(function () { LoadScheduling(); }, time1);
4.日期js(示例:2017/12/22)
var nowtime = new Date(); var time = nowtime.getFullYear() + "-" + nowtime.getMonth() + "-" + nowtime.getDate(); var starttime = time + " 8:40"; var endtime = time + " 9:40"; var stime = new Date(starttime.replace("-", "/").replace("-", "/")); var etime = new Date(endtime.replace("-", "/").replace("-", "/"));
5.下边款虚线
border-bottom: 1px dashed #666;
5.圆角、子间距
border-radius: 19px;
letter-spacing: 2px;
6.MVC跳转列表,打开新窗口
<a href="/Desktop/Scheduling" target="_blank"><span class="<%=btnclass %>"><%=seeAll %></span></a>
7.sql为账户指定默认数据库
8.Regex正则
Regex reg = new Regex(@"^[0-9]*$"); sid = !reg.IsMatch(t) ? "" : sid;
IsMatch():指定的输入字符串中找到的匹配项,找到返回true,否则返回false.
9.允许为null
public ActionResult Scheduling(DateTime? StartTime, DateTime? EndTime, string sid) { DateTime stime = StartTime == null ? DateTime.Now.AddDays(-1) : DateTime.Parse(StartTime.ToString()); DateTime etime = EndTime == null ? DateTime.Now.AddDays(1) : DateTime.Parse(EndTime.ToString());
10.??
string strParam = Request.Params["param"]; if ( strParam== null ) { strParam= ""; } string strParam= Request.Params["param"] == null ? "": Request.Params["param"]; //如果左边为null,取所赋值??右边的 //比如int y = x ?? -1 如果x为空,那么y的值为-1. string strParam= Request.Params["param"]?? "";
另外还有”?(单问号)“修饰符,是System.Nullable的缩写形式,比如
int
?代表是可空的整形,
例如:
int
? a = 1 或者
int
? b=
null