比如从当前时间减去2小时,或者加上2小时。

解决方案 »

  1.   

    exec   master..xp_cmdshell   'date   2008-01-01'   
      exec   master..xp_cmdshell   'time   12:00:00'
      

  2.   

    具体查dateadd()函数吧.以下是简单示例:
    declare @dt1 as datetime,
    @dt2 as datetimeset @dt1=getdate()
    set @dt2=dateadd(hh,2,@dt1)
    select @dt1 as 当前时间,@dt2 as 当前时间加2小时
      

  3.   

    我想楼主的目的不是用sql语句修改系统的时间设置吧.如果那样的话,可以:exec master..xp_cmdshell 'date 2008-01-01'      
    exec master..xp_cmdshell 'time 22:53:00'
      

  4.   

    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)'
      

  5.   

    以下是将当前日期加两天的代码,加两个小时楼主应该会举一反三了吧:
    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)
      

  6.   

    好人做底吧,以下是加两个小时的代码:
    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)