Extract Thread Digit Maturity

Asked

Viewed 2,912 times

2

I have the following digitized line of a billet, I need a function to extract the expiration date from it, and then use in other.

Type line: 74893.12004.21627.007186.37931.981056 1 59490000041480

I know that the 5949 is the billet’s maturity, but I can’t convert to a Date. I mounted the following function but it didn’t work:

function ExtrairDataVencimento(const CodigoBarras: String): TDateTime;
begin
Result := StrToDate('07/10/1997') + StrToInt(Copy(CodigoBarras, 34, 4));
WriteLn(Result);
end;

Any suggestions?

  • Just for the record - digit line format: bbbmL.LLLLLd LLLLL.LLLLLd LLLLL.LLLLLd D FFFFVVVVVVVVVV, being b=bank / m=currency (9=real) / L="Freefield" / d=Block checker digit / D=Digit line checker / F = Maturity Factor (days based on 7 October 1997) / V = Value * 100. - The "Free Field" has data such as agreement number, agency, or other parameters, and varies from database to database.

1 answer

5


See if that’s what you’re looking for:

const
CodigoDeBarras: string = '74893.12004.21627.007186.37931.981056 1 59490000041480';

function ExtrairDataVencimento(const CodigoBarras: String): TDateTime;
begin
Result := StrToDate('07/10/1997') + StrToInt(Copy(CodigoBarras, 41, 4)); // 5949
ShowMessage(DateToStr(Result));
end;

If you’re building a console app:

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  SysUtils;

const
CodigoDeBarras: string = '74893.12004.21627.007186.37931.981056 1 59490000041480';

function ExtrairDataVencimento(const CodigoBarras: String): TDateTime;
begin
Result := StrToDate('07/10/1997') + StrToInt(Copy(CodigoBarras, 41, 4));
Writeln(DateToStr(Result));
end;

begin
ExtrairDataVencimento(CodigoDeBarras);
Readln;
end.

The function DateToStr() converts a value of typeDatatime in a formatted string.

  • you saving me again rsrsrs. Dude, it almost worked, but he showed the wrong date. The boleto won on 20/01/2014, he showed on the show 25/04/2013.

  • yes, you can enter this site and paste it: http://evandro.net/codigo_barras.html

  • 1

    You are using wrong date. The correct basis of the maturity factor is October 7, 1997

  • 1

    @Bacco, perfect your answer, was just that. With the DBX8 code and your answer gave right. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.