请用SQL语句取得数据库服务器当前日期的前30天的日期.

解决方案 »

  1.   

    select convert(varchar(30),getdate()-30,120)
      

  2.   


    --请用SQL语句取得数据库服务器当前日期的前30天的日期.
    select convert(varchar(30),getdate()-30,120)
      

  3.   

    select covert(varchar(50),getdate()-30,120)
      

  4.   

    select convert(varchar(10),dateadd(d,-number,getdate()),120)dt from master..spt_values where type='p' and number<30
    /*
    dt
    ----------
    2011-10-10
    2011-10-09
    2011-10-08
    2011-10-07
    2011-10-06
    2011-10-05
    2011-10-04
    2011-10-03
    2011-10-02
    2011-10-01
    2011-09-30
    2011-09-29
    2011-09-28
    2011-09-27
    2011-09-26
    2011-09-25
    2011-09-24
    2011-09-23
    2011-09-22
    2011-09-21
    2011-09-20
    2011-09-19
    2011-09-18
    2011-09-17
    2011-09-16
    2011-09-15
    2011-09-14
    2011-09-13
    2011-09-12
    2011-09-11(30 行受影响)*/
      

  5.   

    select convert(varchar(30),getdate()-30,120)