Board index » delphi » Date format - BatchMove

Date format - BatchMove

I'm uploading text files into an MSSQL Server database
Everything goes well... except for the date fields
The date format in my text file is 970402 ie YYMMDD without an
DateSeparator.
Although I specified this format in the BDE cfg file, the date fields are
simply left blank without even receiving any ERROR from batchmove

( if i type in the isqlw utility the followin text it does work update
company set time_modify = '970502' where ...

 

Re:Date format - BatchMove


If you are using TBatchMove and the BDE ASCII driver there is no way
to get the BDE ASCII driver to recognize yymmdd as a date. You will
have to convert it to mm/dd/yy format.

Bill

(Sorry but TeamB cannot answer support questions received via email.              )
(To send me email for any other reason remove .nospam from my address.)

Re:Date format - BatchMove


I had the same problem with a poorly managed database in Excel. One field
had a date format (with a separator), and another had a string format. I
just did a loop like so (ex.: 970402) :

procedure Button1Click(Sender : TObject);
var
    s : string;
    i, Y, M, D : Integer;
begin
    Table1.First;
    for i := 1 to Table1.RecordCount do
      begin
         s := Table1Date.Value;
         Y := StrToInt(copy(s, 1, 2));
         M := StrToInt(copy(s, 3, 2));
         D := StrToInt(copy(s, 3, 2));
         Table1ProperDate.Value := EncodeDate(Y, M, D);
         Table1.Next;                          
      end;
end;

Where Table1Date is a TStringField and Table1ProperDate is a TDateField.

Just click on Button1 and let the code convert all your dates one by one.
--

Alain Quesnel

If you reply by e-mail, remove the brackets on
each side of my reply-to address.

Stefan Dewaele <Stefan.Dewa...@rug.ac.be> wrote in article
<01bceaf0$6362c800$212ec...@dialup.rug.ac.be>...

Quote
> I'm uploading text files into an MSSQL Server database
> Everything goes well... except for the date fields
> The date format in my text file is 970402 ie YYMMDD without an
> DateSeparator.
> Although I specified this format in the BDE cfg file, the date fields are
> simply left blank without even receiving any ERROR from batchmove

> ( if i type in the isqlw utility the followin text it does work update
> company set time_modify = '970502' where ...

Other Threads