这样好象不行,我要写在SQL语句中的 如 select * from 表 where 日期字段=#2007-02-15# and 日期字段=#15:30:20#因为我这个日期字段是有日期和时间,只有拆分了才能查询 第一个日期字段取日期 第二个日期字段取时间
楼主,你到底能不能稍微自己动一下脑子呢?上面几位的方法已经把结果存放到变量中了,你可以把这两个变量直接连接进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都有问题,怎么会两个字段同样的名字呢,不管了,楼主自己举的例子自己改吧
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) & "#"
2:用SPLIT函数将空格的前后两段分解到一个数组里就得到前面的日期和后面的时间了
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
my_date=Format(my_datetime, "yyyy-mm-dd")
my_time=Format(my_datetime, "hh:mm:ss")
如
select * from 表 where 日期字段=#2007-02-15# and 日期字段=#15:30:20#因为我这个日期字段是有日期和时间,只有拆分了才能查询
第一个日期字段取日期
第二个日期字段取时间
再帮你写一次:
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都有问题,怎么会两个字段同样的名字呢,不管了,楼主自己举的例子自己改吧
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) & "#"