在今天之前查找包含日期字段的记录 [英] Find records with date field before today
问题描述
我有一张带日期字段的表格。
我想要的所有记录都会在今天之前获得所有记录。
我尝试了以下内容:
" SELECT * FROM StateLicenses Where(Exp<#07/26/2005#)订购者
BranchNo,卫星;"
SELECT * FROM StateLicenses Where(Exp< 07/26/2005)Order By
BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where(Exp <& Now()&")订单按
BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where(Exp<# "& Now()&"#)按订单分类
BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where(Exp<" & FormatDateTime(Now(),2)&
")Order By BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where(Exp< #"& FormatDateTime(Now(),2)&
"#)Order By BranchNo,Satellite;"
并获取错误,例如:
Microsoft OLE DB Provider for ODBC Drivers错误''80040e10''
[Microsoft] [ODBC Microsoft Access驱动程序]参数太少。预期2.
预期数量有时为1,有时为3.
请告诉我我做错了什么。
I have a table with a date field.
All I want to do it get all the records with a date before today.
I tried the following:
"SELECT * FROM StateLicenses Where (Exp < #07/26/2005#) Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < 07/26/2005) Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < " & Now() & ") Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < #" & Now() & "#) Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < " & FormatDateTime(Now(),2) &
") Order By BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < #" & FormatDateTime(Now(),2) &
"#) Order By BranchNo,Satellite;"
and get errors such as:
Microsoft OLE DB Provider for ODBC Drivers error ''80040e10''
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
The expected numbe is sometimes 1 and sometimes 3.
Please tell me what I am doing wrong.
推荐答案
sql =" SELECT * FROM StateLicences WHERE Exp< DATE()"
我假设Exp应该有更好的列名...
"!TG" < 27 ******** @ southwestfunding.com>在留言中写道
新闻:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
sql = "SELECT * FROM StateLicences WHERE Exp < DATE()"
I assume Exp should have a better column name...
"!TG" <27********@southwestfunding.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
我有一个带有日期字段的表。
我想要的所有内容都会在今天之前获得所有记录。
我尝试了以下内容:
SELECT * FROM StateLicenses Where(Exp< ;#07/26/2005#)按订单分类
BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where(Exp< 07/26/2005)Order By
BranchNo,卫星;
SELECT * FROM StateLicenses Where(Exp<& Now()&")Order By
BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where(Exp<#"& Now()&"#)Order By
BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where(Exp<" ;& FormatDateTime(Now(),2)&")
Order By BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where(Exp<#"& FormatDateTime(现在(),2)&
"#)按分数命令chNo,Satellite;
并收到错误,例如:
用于ODBC驱动程序的Microsoft OLE DB提供程序错误''80040e10''
[Microsoft] [ODBC] Microsoft Access驱动程序]参数太少。预期2.
预期数量有时为1,有时为3.
请告诉我我做错了什么。
I have a table with a date field.
All I want to do it get all the records with a date before today.
I tried the following:
"SELECT * FROM StateLicenses Where (Exp < #07/26/2005#) Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < 07/26/2005) Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < " & Now() & ") Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < #" & Now() & "#) Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < " & FormatDateTime(Now(),2) & ")
Order By BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < #" & FormatDateTime(Now(),2) &
"#) Order By BranchNo,Satellite;"
and get errors such as:
Microsoft OLE DB Provider for ODBC Drivers error ''80040e10''
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
The expected numbe is sometimes 1 and sometimes 3.
Please tell me what I am doing wrong.
!TG写道:
我有一个带日期字段的表格。
我想要的所有记录都会在今天之前获得所有记录。
我试过了以下内容:
" SELECT * FROM StateLicenses Where(Exp<#07/26/2005#)Order By
BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where( Exp< 07/26/2005)订单分享
BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where(Exp<& Now()&")Order By
BranchNo,Satellite;"
" SELECT * FROM StateLicenses Where(Exp<#"& Now()&"#)Order By
BranchNo,Satellite;" ;
" SELECT * FROM StateLicenses Where(Exp<&& FormatDateTime(Now(),2)&
")Order By BranchNo,Satellite;"
" ; SELECT * FROM StateLicenses Where(Exp< #" &安培; FormatDateTime(Now(),2)&
"#)按BranchNo,Satellite排序;
并获取错误,例如:
用于ODBC的Microsoft OLE DB提供程序驱动程序错误''80040e10''
[Microsoft] [ODBC Microsoft Access Driver]参数太少。预期2.
预期数量有时为1,有时为3.
请告诉我我做错了什么。
I have a table with a date field.
All I want to do it get all the records with a date before today.
I tried the following:
"SELECT * FROM StateLicenses Where (Exp < #07/26/2005#) Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < 07/26/2005) Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < " & Now() & ") Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < #" & Now() & "#) Order By
BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < " & FormatDateTime(Now(),2) &
") Order By BranchNo,Satellite;"
"SELECT * FROM StateLicenses Where (Exp < #" & FormatDateTime(Now(),2) &
"#) Order By BranchNo,Satellite;"
and get errors such as:
Microsoft OLE DB Provider for ODBC Drivers error ''80040e10''
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
The expected numbe is sometimes 1 and sometimes 3.
Please tell me what I am doing wrong.
" SELECT * FROM StateLicenses Where(Exp<''"& Now()&"'')订购者
BranchNo,卫星;"
-
Curt Christianson
网站: http ://www.darkfalz.com
博客: http: //blog.darkfalz.com
> SELECT * FROM StateLicenses Where(Exp<''"& Now()&"'')Order By
> "SELECT * FROM StateLicenses Where (Exp < ''" & Now() & "'') Order By
BranchNo,Satellite;"
BranchNo,Satellite;"
为什么在数据库之外呢? Access知道NOW()是什么。另外,我认为
不要认为单引号分隔符会正常工作,假设Exp是一个日期
列......
Why do this outside of the database? Access knows what NOW() is. Plus, I
don''t think single quote delimiters will work well, assuming Exp is a Date
column...
这篇关于在今天之前查找包含日期字段的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!