declare @start date,@end date; set @start='2010-01-01'; set @end='2010-02-01'; --获取时间段内日期列表 select [day]=dateadd(day, number - 1, @start) from master.dbo.spt_values where type='P' and number <= datediff(day, @start,@end) + 1 and number>0…
一.获取传入日期所在月的第一天 public static Date getFirstDayDateOfMonth(final Date date) { final Calendar cal = Calendar.getInstance(); cal.setTime(date); final int last = cal.getActualMinimum(Calendar.DAY_OF_MONTH); cal.set(Calendar.DAY_OF_MONTH, last); return ca…
二话不说,先上图 实现如上代码: //获取本周第一天 showWeekFirstDay: function () { let Nowdate = new Date(); let WeekFirstDay = new Date(Nowdate - (Nowdate.getDay() - 1) * 86400000); let M = Number(WeekFirstDay.getMonth()) + 1; if (M < 10) { M = "0" + M; } let D = W…
switch ($type){ case 'day'://当日 $end=date(,,,date(,date('Y'))); $where=' and '.$pre.'create_time>="'.date('Y-m-d').'" and '.$pre.'create_time<="'.$end.'"'; break; case 'week'://获取周数据:往前推6天 $week_start=date(,,,date(,date('Y'))); $…
1.获取时间并且格式化输出 new Date().toLocaleString('cn',{hour12:false}) //2018/12/6 17:57:15 new Date().toLocaleDateString('cn',{hour12:false}) //2018/12/6 new Date().toLocaleTimeString('cn',{hour12:false}) //17:54:01 2.补充分别获取日期和时间 myDate.getYear(); // 获取当前年份(2…
转载自: https://blog.csdn.net/liqinghuiyx/article/details/53333284 起因:在本地开发的WEB项目部署到Linux 下后,存入数据库的时间少了8个小时. 首先想到的肯定是时区问题 linux 下直接 执行 date 命令 Fri Nov 25 11:28:18 CST 2016 时间正常.然后简单java类,打印new Date时间 public class TestDate { public static void main(Strin…
/// 当前月有多少天 /// </summary> /// <param name="y"></param> /// <param name="m"></param> /// <returns></returns> public static int HowMonthDay(int y, int m) { int mnext; int ynext; ) { mnext = m +…
select convert(varchar(7),dateadd(month,number,'2010-01-01'),120) AS MONTHfrom master..spt_valueswhere type='P' and dateadd(month,number,'2010-01-01')<='2010-09-01'…
,'2015-01-01 00:00:00') h INTO vinson_h DELETE vinson_h DECLARE @h int SELECT @h=DATEDIFF(HOUR,'2015-01-01 00:00:00',GETDATE()) WHILE(@num<=@h) BEGIN INSERT INTO vinson_h(h) values (DATEADD(HOUR,@num,'2015-01-01 00:00:00')) END SELECT * FROM vinson_h…