有一个办法把日期当作浮点数来处理
即
var
D1,D2,Ssql:String;
Date1,Date2:TDate;
Begin
D1:=FloatToStr(Date1-1);
D2:=FloatToStr(Date2);
sSql:='select * from Tabel where 日期字段 Between '+D1+' and '+D2;.....
Sql.Add(ssql);
....
end;
即
var
D1,D2,Ssql:String;
Date1,Date2:TDate;
Begin
D1:=FloatToStr(Date1-1);
D2:=FloatToStr(Date2);
sSql:='select * from Tabel where 日期字段 Between '+D1+' and '+D2;.....
Sql.Add(ssql);
....
end;
解决方案 »
- 读取文件的问题
- 求高手解决问题
- 怎么样才能取得联系人的列表
- 急!!!请问哪位达人有dephi的笔试题
- forgot2000中奖了,晕~~~~~~~~
- paradox表对sql语句的支持是不是非常软
- 帮忙写下读取指定数据的正则表达式!!!
- 我做的报表是横放的两个表格,原来表格的宽就变成长,长就变成宽,但是打印时,只打印了一个表另外一个打不出来,请问如何处理
- Delphi 5 的补丁需要注册码。。help me ~~~~~help me ~~~~~help me ~~~~~help me ~~~~~help me ~~~~~help me ~~~~~
- 新手问题,中菜就可以轻易得分,保证40分送出
- 我 需要一 个漂亮的背景,
- 日期转成数字的函数是什么?
SQL.Add(' Where Date >='+#39+Edit1.Text+#39);
不是就可以了吗??
源码如下:
//++++++++++++++++++++++++++++++++++++++++++++
// 功能:将Delphi的日期格式转化为SQL的日期格式
// 参数:
// dDate:Delphi的日期
// 返回值:返回SQL的日期字符串
//++++++++++++++++++++++++++++++++++++++++++++
Function GetSQLDate(dDate:TDateTime):string;
var
Year, Month, Day: Word;
begin
DecodeDate(dDate, Year, Month, Day);
result:=inttostr(Month)+'/'+inttostr(Day)+'/'+inttostr(Year);
end;
// 功能: 获得指定日期所在月的天数
// 参数:
// dDate: 指定日期
// 返回值:返回天数
// 日期:2001/8/11
///////////////////////////////////////////
function GetMonthMaxDay(dDate:TDate):integer;
var
Yr, Mnth, Day: Word;
begin
DecodeDate(dDate, Yr, Mnth, Day);
case Mnth of
1,3,5,7,8,10,12:
Result:=31;
4,6,9,11:
Result:=30;
2:
begin
if IsLeapYear(Yr) And (Mnth=2) then
result:=29
else
result:=28;
end;
else
result:=0;
end;
end;
// 功能:把 SQL(字符串) 的日期该为Delphi的日期(TDate)
// 参数
// SQLDate: SQL 的日期(类似:6/23/2001)
// 返回值:返回 Delphi 的日期
// 日期:2001/6/21
////////////////////////////////////////////////////////
Function Sql2DelphiDate(SQLDate:string):TDate;
var
Year,Month,Day:Word;
i:integer;
begin
Year:=strtoint(myRight(SQLDate,4));
i:=pos('/',SQLDate);
Month:=strtoint(myLeft(SQLDate,i-1));
Day:=strtoint(Copy(SQLDate,i+1,2));
result:=EncodeDate(Year,Month,Day);
end;//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 功能:将Delphi的日期格式转化为短日期格式
// 参数:
// dDate:Delphi的日期
// 返回值:返回断日期字符串
//++++++++++++++++++++++++++++++++++++++++++++
Function GetShortDate(dDate:TDateTime):string;
var
Year, Month, Day: Word;
begin
DecodeDate(dDate, Year, Month, Day);
result:=Copy(inttostr(Year),3,2)+'.'+inttostr(Month)+'.'+inttostr(Day);
end;
where to_date('2001-10-1 12:12:12','yyyy-mm-dd hh24:mi:ss')