SQL获取时间段内的所有月份】的更多相关文章

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'…
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…
,'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…
需求,获取时段内的/var/log/messages文件内出现错误的消息,支持多行的消息,支持天,小时分钟,秒级的区间,可以修改监控的日志对象 #!/bin/bash if [ $# != 1 ] ; then echo "USAGE: $0 num[Y|D|H|M|S]" echo " e.g.: $0 12h" exit 1; fi interval=$1 unit=$(echo $interval | tr -d [:blank:] |tr -d [:digi…
例如查询 2012-1-5 到 2012-11-3 之间所有的月份 declare @begin datetime,@end datetime set @begin='2012-1-5' set @end='2012-11-3' declare @months int set @months=DATEDIFF(month,@begin,@end) select convert(varchar(7),DATEADD(month,number,@begin) ,120) AS 月份 from mas…
declare @begin datetime,@end datetime set @begin='2017-01-01' set @end='2019-03-04' declare @months int set @months=DATEDIFF(month,@begin,@end) ),) AS 月份 from master.dbo.spt_values where type='p' AND number<=@months 查询2017-01-01到2019-03-04之间所有的月份 说明:…
Date.prototype.format=function (){var s='';s+=this.getFullYear()+'-';// 获取年份.s+=(this.getMonth()+1)+"-"; // 获取月份.s+= this.getDate(); // 获取日.return(s); // 返回日期.};function getAll(begin,end){var ab = begin.split("-");var ae = end.split(&q…
declare @dt1 as datetime declare @dt2 as datetime set @dt1 = '2008-01-01' set @dt2 = '2009-01-01' ;with t as (select @dt1 as y union all select dateadd(m,1,y) from t where y <@dt2) select * from t…
    public static void main(String[] args) {        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");        String dateFirst="2017-05-01";        String dateSecond="2017-05-25";        try{            Date st…
public class day { public static void main(String[] args) { // TODO Auto-generated method stub String begintTime = "2019-03-26"; String endTime = "2019-03-04"; for(String days: findDaysStr(begintTime,endTime)){ System.out.println(days)…