LPAD in T-SQL and Crystal Report Formula

I am sure there should have some neater ways to do this but if all you need are just working version, here it goes.


REPLICATE('0', 8 - LEN(LTRIM(STR(YourTableField)))) + LTRIM(STR(YourTableField))

Crystal Report Formula

StringVar Message := "";
StringVar Num := {YourCrystalReportTable.Field};
Num := Trim (Num);
NumberVar Counter := 8 - Length(Num) ;
While (Counter > 0) do
Message := Message & "0";
Counter := Counter - 1;
Message := Message & Num


Popular posts from this blog

Clearcase check in/uncheck out all the checked out files script

Duplicating a local copy of project from TFS and making web software client factory to work