DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: sharehb
今日帖子: 28
在线用户: 19
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/2/5 19:55:08
标题:
SQL语句如何修正? 浏览:1993
加入我的收藏
楼主: 偶在database sql explorer中写的sql
出了错!

是关于查询 两个日期之间的:

此帖子包含附件:
JPEG 图像
大小:45.8K
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
男 axsoft (axsoft) ★☆☆☆☆ -
盒子活跃会员
2004/2/5 20:46:57
1楼: 日期用引号。
----------------------------------------------
-
作者:
男 maimaizhi (muting) ★☆☆☆☆ -
普通会员
2004/2/5 20:48:10
1楼: where (hdate>='1/1/2004') and (hdate <='1/20/2004')
----------------------------------------------
-
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/2/5 21:05:40
2楼: 谢谢大哥 偶试试
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/2/5 21:10:40
3楼: 老大还是出错呀,偶这个字段是date型的
此帖子包含附件:
JPEG 图像
大小:38.8K
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
男 maimaizhi (muting) ★☆☆☆☆ -
普通会员
2004/2/5 22:06:57
4楼: 是什么数据库?
----------------------------------------------
-
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/2/5 22:07:58
5楼: paradox数据库啊!大哥救偶
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
男 maimaizhi (muting) ★☆☆☆☆ -
普通会员
2004/2/6 2:35:02
6楼: procedure TForm1.Button1Click(Sender: TObject);
var
   strSql:string;
begin
  query1.Close ;
  query1.SQL.Clear ;
  strSql:='select * from hdate where (hdate>='1/1/2003') and (hdate<='1/1/2004')';
  query1.SQL.Add(strSql);
  query1.Open;
end;
----------------------------------------------
-
作者:
女 haikely (阿) ★☆☆☆☆ -
盒子活跃会员
2004/2/6 8:37:20
7楼: 利用参数吧:
  Query1.Close;
  Query1.SQL.Clear;
  Query1.SQL.Add(Select * From "lll" Where Hdate Between :Data1 and :Data2;)
  Query1.ParamByName('Data1').AsDateTime:=<你的第一个时间>;
  Query1.ParamByName('Data2').AsDateTime:=<你的第二个时间>;
  Query1.Prepare;
  Query1.Open;
----------------------------------------------
-
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/2/6 9:41:54
8楼: 老大偶是说在 DELPHI的database sqlexploer里敲啊!
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
女 haikely (阿) ★☆☆☆☆ -
盒子活跃会员
2004/2/6 11:30:15
9楼: There are two acceptable formats for the date parts of DATE and TIMESTAMP literals in local SQL statements: the US date format and the European date format. Which one of the two you use is predicated on the Windows configuration settings for Date Separator and Short Date Style. If the Date Separator is a slash (/) and Short Date Style puts the month before the day (such as MM-dd-yy), the date must be in a US date format, MM/DD/YY or MM/DD/YYYY. If the Date Separator is a period (.) and Short Date Style puts the day before the month (such as dd.MM.yy), the date must be in a European date format, DD.MM.YY or DD.MM.YYYY. A combination of Short Date Style of month before day and a Date Separator of anything but a period is not supported in local SQL. DATE and TIMESTAMP values passed to an SQL statement via parameters and the values in columns are unaffected by these restrictions on format. Only literal values are affected.

To prevent date literals from being mistaken by the SQL parser for arithmetic calculations, enclose them in quotation marks. This keeps 1/23/1998 from being mistaken for 1 divided by 23 divided by 1998.

Example of a date literal in a US format:

SELECT *

FROM Orders

WHERE (SaleDate <= "1/23/1998")

Example of the same date literal in a European format:

SELECT *

FROM Orders

WHERE (SaleDate <= "23.1.1998")

Leading zeros for the month and day fields are optional.

If the century is not specified for the year in a date value, the BDE settings FOURDIGITYEAR and YEARBIASED control the century of the date.
----------------------------------------------
-
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/2/6 11:43:44
10楼: 谢谢大哥偶试试!
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/2/6 12:04:05
11楼: 老大 始终不行啊
select * from "111.db" where hdate>="2004/1/1" and hdate<="2004/1/20"
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
男 maimaizhi (muting) ★☆☆☆☆ -
普通会员
2004/2/6 13:07:37
12楼: select * from lll where hdate>='1/1/2004' and hdate <='1/20/2004'
----------------------------------------------
-
作者:
男 maimaizhi (muting) ★☆☆☆☆ -
普通会员
2004/2/6 13:14:44
13楼: paradox日期格式是: 月/日/年
sqlserver日期格式是: 年-月-日


----------------------------------------------
-
作者:
男 jasonmao (jason) ★☆☆☆☆ -
普通会员
2004/2/6 13:21:25
14楼: 实在不行用格式转换函数试下.
----------------------------------------------
我真的很菜啊。
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/2/6 13:25:39
15楼: 非常感谢!
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行93.75毫秒 RSS