Dim dt1 As String
Dim dt2 As String
Dim dt3 As Integer
Do While Not Adodc1.Recordset.EOF
   With Adodc1.Recordset
'如果规定时间小于实际上班时间,那么求两者之间的差,取分钟,再用分钟除以15求整。
   If CDate(Text7.Text) < CDate(Text6.Text) Then
      dt1 = cstr(dateadd("n",-CDate(Text7.Text), CDate(Text6.Text))
          dt3 = cint(dt1) \ 15
      Text9.Text = CStr(dt3)
   End If
   .MoveNext
   End With
Loop帮我看看这段代码,dt1求出来的始终是空的。

解决方案 »

  1.   

    DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])
    返回 Variant (Long) 的值,表示两个指定日期间的时间间隔数目。
      

  2.   

    你怎么用DATE呢 应该用TIME呀...
      

  3.   

    看不明白……如果是在界面窗口里取数据比较,为什么要放到记录集的循环里?如果是记录集的字段值比较,
    “dt1 = cstr(dateadd("n",-CDate(Text7.Text), CDate(Text6.Text))
              dt3 = cint(dt1) \ 15”
    是不是应该换成.Recordset.fileds()?
      

  4.   

    fuanwei,你好,你可以帮我用datediff,按我的那段代码改写一下吗?我非常着急了。谢谢
      

  5.   

    yyyy 年 
    q 季 
    m 月 
    y 一年的日数 
    d 日 
    w 一周的日数 
    ww 周 
    h 时 
    n 分钟 
    s 秒 
    dt1=datediff("n",cdate(text7.text),cDate(text6.text))