已知现在是2009年8月10日,下面是表m:
              
               产品编号     安装时间     保质期(年)
                 1          2006-01-01     2
                 2          2006-08-08     3
                 3          2007-09-09     4各位:怎么求过了保质期的产品编号????sql语句怎么写啊??!!!!!
 

解决方案 »

  1.   

    当前日期和安装日期的年数差大于保质期的就过期
    SQL Server求年数差的函数DATEDIFF
      

  2.   


    已知现在是2009年8月10日,下面是表m: 
                  
                  产品编号    安装时间        过保时间 
                    1      2006-01-01    2008-01-01 
                    2      2006-08-08    2009-08-08 
                    3      2007-09-09    2011-09-09 各位:怎么求过了保质期的产品编号????sql语句怎么写啊??!!!!!
      

  3.   

    已知现在是2009年8月10日,下面是表m: 
                  
                  产品编号    安装时间        过保时间 
                    1      2006-01-01    2008-01-01 
                    2      2006-08-08    2009-08-08 
                    3      2007-09-09    2011-09-09 各位:怎么求过了保质期的产品编号????sql语句怎么写啊??!!!!!
      

  4.   

    select * from table
    where getdate() > DATEADD(year,保质期(年) ,安装时间  )
      

  5.   


    已知系统时间是2009年8月10日,下面是表m: 
                  
                  产品编号    安装时间        过保时间 
                    1      2006-01-01    2008-01-01 
                    2      2006-08-08    2009-08-08 
                    3      2007-09-09    2011-09-09 各位:怎么求过了保质期的产品编号????sql语句怎么写啊??!!!!!
      

  6.   

    已知系统时间是2009年8月10日,下面是表m: 
                  
                  产品编号    安装时间        过保时间 
                    1      2006-01-01    2008-01-01 
                    2      2006-08-08    2009-08-08 
                    3      2007-09-09    2011-09-09 各位:怎么求过了保质期的[color=#008000]产品编号
    ????sql语句怎么写啊??!!!!! [/color]
      

  7.   

    select * from table 
    where getdate() > DATEADD(year,保质期(年) ,安装时间  ) 或者select * from table
    where 保质期(年)〈 DATEDIFF(year, 安装时间,getdate())
      

  8.   

    呵呵 建议楼主多了解一下SQL系统函数
      

  9.   

    到SQL 区去问 很快有答案
      

  10.   

     
    产品编号    安装时间        过保时间 (old)           是否过期(flag)
        1      2006-01-01        2
       2      2006-08-08        3
       3      2007-09-09        4update m set flag = "y" where DateAdd(yyyy, old,getdate()) > getdate()
    我刚才理解的 请高手说下对不对  谢谢
      

  11.   

    [ode=SQL]where DateAdd(yyyy, old,datetime(安装日期)) < getdate()[/code]太粗心了
      

  12.   


    create table #T
    (
    id int,
    indate datetime,
    Saveyear int 
    )
    insert into #T 
    select  1,'2006-01-01',2 
    union select 2,'2006-08-08',3 
    union select 3,'2007-09-09',4 select id from #T
    where dateadd(year,Saveyear,indate)<getdate()drop table #T
      

  13.   


    点击button之后怎么让dataGridView控件变为自己设定的尺寸????????
    我写的是错的" private void button1_Click(object sender, EventArgs e)
            {
                groupBox1.Visible = true;
                dataGridView1.Size = System.Drawing.Size(650, 317);
            }
      

  14.   


    点击button之后怎么让dataGridView控件变为自己设定的尺寸????????
    我写的是错的" private void button1_Click(object sender, EventArgs e)
            {
                groupBox1.Visible = true;
                dataGridView1.Size = System.Drawing.Size(650, 317);
            }
      

  15.   

    不是,我以前没涉及到这个问题,这次是突然有这个要求,不太会了,已知系统时间是2009年8月10日,下面是表m: 
                  
                  产品编号    安装时间        过保时间 
                    1      2006-01-01    2008-01-01 
                    2      2006-08-08    2009-08-08 
                    3      2007-09-09    2011-09-09 各位:怎么求过了保质期的[color=#008000]产品编号????
      

  16.   


    SELECT * FROM TEST WHERE  GETDATE()<D2 AND FLAG='N' D2是日期类型的