表:student   字段:姓名(char(50))     入学日期 date()select * from student where 入学日期=  (03-12-11)
                            入学日期 属于03年12月
 各该如何表达?

解决方案 »

  1.   

    select select * from student where 入学日期= '2003-12-11'
      

  2.   

    日期字段的查询与数据库类型有关.ACCESS数据库用:
    select * from student where 入学日期=#03-12-11#
    SQL数据库中用:
    select * from student where 入学日期='03-12-11'
      

  3.   

    VB中编程:
        dim strSql   as string 
        dim strDate  as string    strDate = "03-12-11" '或输入字符串
        strSql = "select * from student where 入学日期=" & "'" & strDate & "'"
        使用Recordset打开记录集即可
      

  4.   

    查询和VB没有关系
    要看数据库支持的SQL语法,
    比如SQL Server将日期放在''之间,Access将日期放在##之间。
      

  5.   

    日期字段的查询与数据库类型、日期格式有关ACCESS数据库用:
    select * from student where format(入学日期,'yyyy-mm-dd')=#2003-12-11#
    SQL数据库中用:
    select * from student where convert(char(10),入学日期,21)='2003-12-11'将格式统一后不容出错!!
      

  6.   

    你可以看一看下面的帖子,可能对你有所帮助的
    http://expert.csdn.net/Expert/topic/2095/2095394.xml?temp=.3669855
      

  7.   

    ACCESS数据库用:
    select * from student where 入学日期=#03-12-11#
    SQL数据库中用:
    select * from student where 入学日期='03-12-11'
      

  8.   

    ACCESS
    select * from student where format(入学日期,'yyyy-mm-dd')=#2003-12-11#
    SQL
    select * from student where format(入学日期,'yyyy-mm-dd')='03-12-11'
      

  9.   

    ACCESS数据库用:
    select * from student where 入学日期=#03-12-11#
    SQL数据库中用:
    select * from student where 入学日期='03-12-11'
      

  10.   

    ACCESS数据库用:
    select * from student where 入学日期=#03-12-11#
    SQL数据库中用:
    select * from student where 入学日期='03-12-11'其实主要一个就是格式的问题,只要你比较前将格式为一致就可以正确地区比较了
      

  11.   

    select * from student where [入学日期] =  #03-12-11#
    ACCESS数据库用#分隔日期,其它数据库用单引号!!如果查不到,可能是日期里面带时间,用BETWEEN试一下!!
      

  12.   

    access中时间查找要用"#"号隔开
      

  13.   

    ACCESS数据库用:
    select * from student where 入学日期 >= #03-12-01# and 入学日期 <= #03-12-31#
    SQL数据库中用:
    select * from student where 入学日期 >= '03-12-01' and 入学日期 <= '03-12-31'
      

  14.   

    select * from student where 入学日期 = '03-12'请问你入学日期的存储格式!!!
      

  15.   

    select * from student where LEFT(入学日期 ,5)= '03-12'
      

  16.   

    select * from student where 入学日期 >= '03-12-01' and 入学日期 <= '03-12-31'
    我认为这样写也没有错呀!!!!!!!!!
      

  17.   

    呵呵,看了前面的高手回复,我就不多说了,总之SQL和ACCESS数据库是不一样的!我再说一点的就是在SQL中可以用convert转换时间变量,比如你这个语句也可以这样写
    select * from student where 入学日期=convert(varchar(10),'03-12-31',120)
    在VB中可以这样写
        Dim sSql As String
        Dim rsData As New ADODB.Recordset    sSql="select * from student where 入学日期='" & format('03-12-31',"yyyy-mm-dd") & "'"如果是ACCESS数据库,在VB中可以这样写
        sSql="select * from student where 入学日期=#" & format('03-12-31',"yyyy-mm-dd") & "#"
      

  18.   

    "select * from student where 入学日期=(03-12-11) and 入学日期 between '2003-12-01' and '2003-12-31'"