比如我的ACCESS有一个日期类型的字段,如;
2007-08-12 16:20:00
我想分别取出日期部门和时间部分,谢谢!

解决方案 »

  1.   

    1:将字段内容读到STRING变量中
    2:用SPLIT函数将空格的前后两段分解到一个数组里就得到前面的日期和后面的时间了
      

  2.   

    Private Sub Form_Load()
    Dim d As String, a() As String
    d = "2007-08-12 16:20:00"
    a = Split(d, Space(1))
    Debug.Print a(0)
    Debug.Print a(1)
    End Sub
      

  3.   

    my_datetime="2007-08-12 16:20:00"
    my_date=Format(my_datetime, "yyyy-mm-dd")
    my_time=Format(my_datetime, "hh:mm:ss")
      

  4.   

    这样好象不行,我要写在SQL语句中的

    select * from 表 where 日期字段=#2007-02-15# and 日期字段=#15:30:20#因为我这个日期字段是有日期和时间,只有拆分了才能查询
    第一个日期字段取日期
    第二个日期字段取时间
      

  5.   

    楼主,你到底能不能稍微自己动一下脑子呢?上面几位的方法已经把结果存放到变量中了,你可以把这两个变量直接连接进SQL语句里去呀:
    再帮你写一次:
    Dim d As String, a() As String
    d = "2007-08-12 16:20:00"
    a = Split(d, Space(1))
    DIM SQL AS STRING
    Debug.Print a(0)
    Debug.Print a(1)
    SQL="select * from 表 where 日期字段=#" & a(0) & "# and 日期字段=#" & a(1) & "#"
    ...
    似乎这样的SQL都有问题,怎么会两个字段同样的名字呢,不管了,楼主自己举的例子自己改吧
      

  6.   

    Dim d As String, a() As String
    d = "2007-08-12 16:20:00"
    a = Split(d, Space(1))
    DIM SQL AS STRING
    Debug.Print a(0)
    Debug.Print a(1)
    SQL="select * from 表 where 日期字段=#" & a(0) & "# and 日期字段=#" & a(1) & "#"