select select * from student where 入学日期= '2003-12-11'
日期字段的查询与数据库类型有关.ACCESS数据库用: select * from student where 入学日期=#03-12-11# SQL数据库中用: select * from student where 入学日期='03-12-11'
VB中编程: dim strSql as string dim strDate as string strDate = "03-12-11" '或输入字符串 strSql = "select * from student where 入学日期=" & "'" & strDate & "'" 使用Recordset打开记录集即可
日期字段的查询与数据库类型、日期格式有关ACCESS数据库用: select * from student where format(入学日期,'yyyy-mm-dd')=#2003-12-11# SQL数据库中用: select * from student where convert(char(10),入学日期,21)='2003-12-11'将格式统一后不容出错!!
ACCESS数据库用: select * from student where 入学日期=#03-12-11# SQL数据库中用: select * from student where 入学日期='03-12-11'
ACCESS select * from student where format(入学日期,'yyyy-mm-dd')=#2003-12-11# SQL select * from student where format(入学日期,'yyyy-mm-dd')='03-12-11'
ACCESS数据库用: select * from student where 入学日期=#03-12-11# SQL数据库中用: select * from student where 入学日期='03-12-11'
ACCESS数据库用: select * from student where 入学日期=#03-12-11# SQL数据库中用: select * from student where 入学日期='03-12-11'其实主要一个就是格式的问题,只要你比较前将格式为一致就可以正确地区比较了
select * from student where [入学日期] = #03-12-11# ACCESS数据库用#分隔日期,其它数据库用单引号!!如果查不到,可能是日期里面带时间,用BETWEEN试一下!!
access中时间查找要用"#"号隔开
ACCESS数据库用: select * from student where 入学日期 >= #03-12-01# and 入学日期 <= #03-12-31# SQL数据库中用: select * from student where 入学日期 >= '03-12-01' and 入学日期 <= '03-12-31'
select * from student where 入学日期 = '03-12'请问你入学日期的存储格式!!!
select * from student where LEFT(入学日期 ,5)= '03-12'
select * from student where 入学日期 >= '03-12-01' and 入学日期 <= '03-12-31' 我认为这样写也没有错呀!!!!!!!!!
呵呵,看了前面的高手回复,我就不多说了,总之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") & "#"
"select * from student where 入学日期=(03-12-11) and 入学日期 between '2003-12-01' and '2003-12-31'"
select * from student where 入学日期=#03-12-11#
SQL数据库中用:
select * from student where 入学日期='03-12-11'
dim strSql as string
dim strDate as string strDate = "03-12-11" '或输入字符串
strSql = "select * from student where 入学日期=" & "'" & strDate & "'"
使用Recordset打开记录集即可
要看数据库支持的SQL语法,
比如SQL Server将日期放在''之间,Access将日期放在##之间。
select * from student where format(入学日期,'yyyy-mm-dd')=#2003-12-11#
SQL数据库中用:
select * from student where convert(char(10),入学日期,21)='2003-12-11'将格式统一后不容出错!!
http://expert.csdn.net/Expert/topic/2095/2095394.xml?temp=.3669855
select * from student where 入学日期=#03-12-11#
SQL数据库中用:
select * from student where 入学日期='03-12-11'
select * from student where format(入学日期,'yyyy-mm-dd')=#2003-12-11#
SQL
select * from student where format(入学日期,'yyyy-mm-dd')='03-12-11'
select * from student where 入学日期=#03-12-11#
SQL数据库中用:
select * from student where 入学日期='03-12-11'
select * from student where 入学日期=#03-12-11#
SQL数据库中用:
select * from student where 入学日期='03-12-11'其实主要一个就是格式的问题,只要你比较前将格式为一致就可以正确地区比较了
ACCESS数据库用#分隔日期,其它数据库用单引号!!如果查不到,可能是日期里面带时间,用BETWEEN试一下!!
select * from student where 入学日期 >= #03-12-01# and 入学日期 <= #03-12-31#
SQL数据库中用:
select * from student where 入学日期 >= '03-12-01' and 入学日期 <= '03-12-31'
我认为这样写也没有错呀!!!!!!!!!
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") & "#"