VB数据库问题

anwar 2000-07-11 01:25:00
在VB按日期型字段查询怎么进行?
...全文
91 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
skt642 2001-05-31
  • 打赏
  • 举报
回复
61626关注!
Longe 2000-07-11
  • 打赏
  • 举报
回复
如果是自己编写的内嵌在程序中的查询条件式,我觉得把从数据字段中取出的数据转换成文本格式再进行检索,速度比较快些。
如:
(Access)
'open database
set db_in=...
'open table
set tb_in=...
do until tb_in.eof
if tb_in([日期字段的字段号])="检索条件" then
print tb_in(1)
end if
tb_in.movenext
loop
tb_in.close
db_in.close

liyang 2000-07-11
  • 打赏
  • 举报
回复
Access中用#1999-1-2#
Sql Server中用 SELECT * FROM Northwind.dbo.Orders WHERE OrderDate < 'May 1, 1997' or ‘4/15/1998’

另:有关Sql Server的DateTime如下:
When specifying dates in comparisons or for input to INSERT or UPDATE statements, use constants that are interpreted the same for all language settings:
ADO, OLE DB, and ODBC applications should use the ODBC timestamp, date, and time escape clauses of:
{ ts 'yyyy-mm-dd hh:mm:ss[.fff] '} such as: { ts '1998-09-24 10:02:20' }
{ d 'yyyy-mm-dd'} such as: { d '1998-09-24' }
{ t 'hh:mm:ss'} such as: { t '10:02:20'}
Applications using other APIs, or Transact-SQL scripts, stored procedures, and triggers should use the unseparated numeric strings for example: yyyymmdd as 19980924.
Applications using other APIs, or Transact-SQL scripts stored procedures, and triggers can also use the CONVERT statement with an explicit style parameter for all conversions between the date and smalldate data types and character string data types. For example, this statement is interpreted the same for all language or date format connection settings:
SELECT *

FROM Northwind.dbo.Orders

WHERE OrderDate = CONVERT(DATETIME, '7/19/1996', 101)


czq 2000-07-11
  • 打赏
  • 举报
回复
注意不同数据库的格式
查询很简单。。

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧