sql – 获取明天的日期

我试图让明天的日期在一个sql语句进行日期比较,但它不工作.

以下是我的代码

select * 
from tblcalendarentries
where convert(varchar,tblcalendarentries.[Start Time],101) 
      = convert(varchar,GETDATE() +1,101)

解决方法

要获得明天的日期,您可以使用:
SELECT DATEADD(day,1,GETDATE())

所以在where子句中添加到你的代码中:

where convert(varchar,101) = 
      convert(varchar,DATEADD(day,GETDATE()),101)

首先,GETDATE()将以以下格式获取今天的日期:

2013-04-16 10:10:02.047

07000

Returns the current database system timestamp as a datetime value without the database time zone offset. This value is derived from the operating system of the computer on which the instance of sql Server is running.

然后使用DATEADD(),允许您从指定的日期添加(或减少必要的)日期或时间间隔.所以间隔可以是:年,月,日,小时,分钟等

07001

Returns a specified date with the specified number interval (signed integer) added to a specified datepart of that date.

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...