发布网友 发布时间:2022-04-30 08:52
共3个回答
懂视网 时间:2022-04-30 13:13
@startDate DATE; DECLARE @startDateTime DATETIME; DECLARE @endDateTime DATETIME ; SET @startDate=GETDATE(); SELECT @startDateTime=DATEADD(DAY,-1,@startDate); SET @endDateTime=DATEADD(second,-1,CONVERT(DATETIME,@startDate)) print(@startDateTime) print(CONVERT(DATETIME,@startDate)) print(@startDate) print(@endDateTime)
三、动态SQL语句
DECLARE @startDate DATE; DECLARE @startDateTime DATETIME; DECLARE @endDateTime DATETIME ; SET @startDate=GETDATE(); SELECT @startDateTime=DATEADD(DAY,-1,@startDate); SET @endDateTime=DATEADD(second,-1,CONVERT(DATETIME,@startDate)) declare @sql nvarchar(1000) set @sql=‘select * from E_OrdersLogistics where ForecastTime>=‘‘‘+cast(ISNULL(@startDateTime,‘‘) as nvarchar(100)) +‘‘‘ and ForecastTime<‘‘‘+CAST(ISNULL(@endDateTime,‘‘) as nvarchar(100))+‘‘‘‘ print(@sql) exec(@sql)
如需转载,请注明出处,谢谢大家支持~
SQL获取前一天0:00:00至23:59:59数据
标签:
热心网友 时间:2022-04-30 10:21
select热心网友 时间:2022-04-30 11:39
where 字段 between 日期1 and 日期2