日期范围应该怎么样处理好?
假如有日期范围‘2004-04-28’       ‘2004-08-28’
而数据库字段Log_Time的日期是型如‘2004-05-28 16:08:37’
应如何作比较好?where子句怎么写?

解决方案 »

  1.   

    这样可以忽略那个时候了.
    Private Sub Command15_Click()
    Dim db As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim a As Date, b As Date
    a = #4/28/2004 5:41:32 PM#
    b = #8/28/2004 5:41:32 PM#
    db.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & "data source=" & App.Path & "\AAA.mdb"
    db.Open
    rs.Open "select * from TABLENAME where YearMonthDateTime between  #" & a & "# and #" & b & "#", dbEnd Sub
      

  2.   

    在MS SQLServer里面用: where Log_Time between ‘2004-04-28’ and ‘2004-08-28’  
      

  3.   

    用between ...and ....
    它的范围
    是包括前面的日期 还是 包括后面的日期的?
    或是两者都包在范围内?
      

  4.   

    between  a and b 相当于a<=logtime and logtime <=b