community.borland.com

Article #25895: How to get date "2000-05-01" in a text file insert it into InterBase date?

Problem:
How to get date "2000-05-01" in a text file insert it into InterBase date?  



Solution:
InterBase doesn't like the format "yyyy/mm/dd" as input to the datatype date.  To workaround it, input the elements
separately and then concantenate and then cast to date.  Something like this:

text file date.txt has:
----------------------------
2000-05-0104:30:45

====================
Running the following to create external table and internal table and insert the data from one talbe to the other.

create database "test1.gdb" user "sysdba" password "masterkey";

create table ext_tbl external file "c:testtempdate.txt" (f_year char(4), 
f_dash1 char(1),
f_month char(2),
f_dash2 char(1),
f_date char(2),
f_hour char(2),
f_col1 char(1),
f_min char(2),
f_col2 char(1),
f_sec char(2),newline char(2));

create table int_tbl (f1 date);

insert into int_tbl select cast(f_month||f_dash1||f_date||f_dash2||f_year||" " 
||f_hour||f_col1||f_min||f_col2||f_sec as date) from ext_tbl;

select * from int_tbl;


commit;
================================================



Last Modified: 18-OCT-00