如何将插入的Orcle数据库里的日期类型为yyyy-mm-dd hh-mi-ssDateTimes:=Now;
with qry do begin
SQL.Clear();
SQL.Add('insert into testDate (TestDateTime) values (:TestDateTime)');
Parameters.ParamByName('TestDateTime').Value := DateTimes;
ExecSQL;
end;插入数据库中的只有日期。没有时间。。现在要插入时间改怎么操作啊????谢谢
这个DateTimes最后的格式都是正确的。。但是插入数据库中就只有日期了。
with qry do begin
SQL.Clear();
SQL.Add('insert into testDate (TestDateTime) values (:TestDateTime)');
Parameters.ParamByName('TestDateTime').Value := DateTimes;
ExecSQL;
end;插入数据库中的只有日期。没有时间。。现在要插入时间改怎么操作啊????谢谢
这个DateTimes最后的格式都是正确的。。但是插入数据库中就只有日期了。
Parameters.ParamByName('D').Value:=now(); 就可以把时间部分也插入进去.
Oracle 中 日期类型 只有date.
rqsj:=FormatDateTime('yyyy-mm-dd hh:nn:ss',now);SQL.Add('insert into testDate (TestDateTime) values TO_DATE('''+rqsj+''',''YYYY/MM/DD HH24:MI:SS'')');
一直这么用!
我程序中已經在跑了.下面是我程序中的代碼
with adoquery2 do //往 CurrUser 中插入登錄信息
begin
close;
sql.Clear;
sql.Add('insert into CurrUser(username,hostname,hostIP,logindate,logincount)');
sql.Add('values(:A,:B,:C,:D,:E)');
Parameters.ParamByName('A').Value:=adoquery1.FieldValues['username'];
Parameters.ParamByName('B').Value:=hostname;
Parameters.ParamByName('C').Value:=hostIP;
Parameters.ParamByName('D').Value:=now();
Parameters.ParamByName('E').Value:=logincount;
Execsql;
end;
下面是我數據庫中的資料
ADMINISTRATOR test-erp 192.168.200.73 2007-09-21 14:14:15 Login in
ADMINISTRATOR test-erp 192.168.200.73 2007-09-21 14:15:54 Login out
ADMINISTRATOR b61ffd17f9334b9 192.168.56.129 2007-09-21 14:39:36 Login in
ADMINISTRATOR b61ffd17f9334b9 192.168.56.129 2007-09-21 14:39:46 Login out
ADMINISTRATOR test-erp 192.168.200.73 2007-09-22 07:37:37 Login in
ADMINISTRATOR test-erp 192.168.200.73 2007-09-22 07:38:16 Login out
ADMINISTRATOR test-erp 192.168.200.73 2007-09-22 08:01:43 Login in
---------------------------
1 NUI sheron-nb 192.168.200.194 2009-01-08 08:13:58 1
剛才發的數據是用戶登陸日誌表,現在這個才是用戶登陸記錄表.當用戶退出系統時,則會在該表中刪除對應的登陸記錄.此錶始終顯示的目前正在登陸的用戶信息.
rqsj:=FormatDateTime('yyyy-MM-dd hh:mm:ss',now);//mm代表分MM才是月
with qry do
begin
SQL.Clear();
Parameters.Clear;
SQL.Add('insert into testDate (TestDateTime) values (to_date(:TestDateTime, 'yyyy-mm-dd hh:nn:ss'))');
Parameters.ParamValues['TestDateTime'] := FormatDateTime('yyyy-mm-dd hh:nn:ss',DateTimes);
ExecSQL;
end;
试试吧 兄弟!
(Sno,SName,SBirthday,SSex)
VALUES
(‘Y20101’,’张一某’,TO_DATE(‘1982-12-15’,’YYYY-MM-DD’),1);
用TO_DATE转换一下就行啊