有没有修改系统时间的命令? 比如从当前时间减去2小时,或者加上2小时。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 exec master..xp_cmdshell 'date 2008-01-01' exec master..xp_cmdshell 'time 12:00:00' 具体查dateadd()函数吧.以下是简单示例:declare @dt1 as datetime, @dt2 as datetimeset @dt1=getdate()set @dt2=dateadd(hh,2,@dt1)select @dt1 as 当前时间,@dt2 as 当前时间加2小时 我想楼主的目的不是用sql语句修改系统的时间设置吧.如果那样的话,可以:exec master..xp_cmdshell 'date 2008-01-01' exec master..xp_cmdshell 'time 22:53:00' declare @dt1 as datetime, @dt2 as datetimeset @dt1=getdate()set @dt2=dateadd(hh,2,@dt1)exec master..xp_cmdshell 'date 2008-01-01'exec master..xp_cmdshell 'time ' + 'dateadd(hh,2,@dt1)' 以下是将当前日期加两天的代码,加两个小时楼主应该会举一反三了吧:declare @d1 datetime,@d2 datetime,@str varchar(100)set @d1=getdate()set @d2=dateadd(day,2,getdate())set @str='exec master..xp_cmdshell ''date '+convert(char(10),@d2,120)+''''print @strexec (@Str) 好人做底吧,以下是加两个小时的代码:declare @d1 datetime,@d2 datetime,@str varchar(100)set @d1=getdate()set @d2=dateadd(hh,-2,getdate())set @str='exec master..xp_cmdshell ''time '+convert(char(10),@d2,108)+''''print @strexec (@Str) 问一个关于递归搜索(子树)的问题 BCP过滤 建立表与表之间的关系(如父子表),从性能上讲,是好是坏呢???肯定结帖 HOST_Name的问题 请问这个sql怎么写。来者有分! 让缘随风 17:28:13 请教一下,一个表DB8 ID WX 1 A 2 A 3 B 4 B 5 求一条select 语句 在存储过程中建表,表名可以用变量吗? 关于复制,分布式数据库的若干问题,回答有效任何一个问题者,均给分啊,请高手指教!!! 游标只读问题?不能用作Delete or Update 多表查询(外查询) 一个特殊的sql语句?有关于sum与case的用法
exec master..xp_cmdshell 'time 12:00:00'
declare @dt1 as datetime,
@dt2 as datetimeset @dt1=getdate()
set @dt2=dateadd(hh,2,@dt1)
select @dt1 as 当前时间,@dt2 as 当前时间加2小时
exec master..xp_cmdshell 'time 22:53:00'
@dt2 as datetimeset @dt1=getdate()
set @dt2=dateadd(hh,2,@dt1)
exec master..xp_cmdshell 'date 2008-01-01'
exec master..xp_cmdshell 'time ' + 'dateadd(hh,2,@dt1)'
declare @d1 datetime,@d2 datetime,@str varchar(100)set @d1=getdate()
set @d2=dateadd(day,2,getdate())
set @str='exec master..xp_cmdshell ''date '+convert(char(10),@d2,120)+''''
print @strexec (@Str)
declare @d1 datetime,@d2 datetime,@str varchar(100)set @d1=getdate()
set @d2=dateadd(hh,-2,getdate())
set @str='exec master..xp_cmdshell ''time '+convert(char(10),@d2,108)+''''
print @strexec (@Str)