Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date format spacing 1

Status
Not open for further replies.

ejastia

Technical User
Sep 3, 2012
62
PH


Hi!

I'm using the date format 12 31 2022. No separator. How am I going to put space between month, day and year in digits? Example, 1 2 3 1 2 0 2 2.


Thank you.
 
Assuming that the field you are working with is genuinely a date, this should work:

Code:
WhilePrintingRecords;

Local StringVar a := ToText({Table.Field}, 'MM dd yyyy');
Local NumberVar b := Len(a);
Local NumberVar i;
Local StringVar RESULT := '';

for i := 1 to b Step 1 do
RESULT := RESULT + Mid(a, i,1) + ' ';

Replace(RESULT, '  ', ' ')

If the field you are working with is not a date field, the approach will need to change. Please let us know how you go.

Regards,
Pete.
 
Hi!

with error "bad number format string". then this was highlited.


whilePrintingRecords;

Local StringVar a := [highlight #FCE94F]ToText({ARRFH.DOCDATE},'MM dd yyyy');[/highlight]
Local Numbervar b :=Len(a);
Local Numbervar i;
Local Stringvar RESULT := ' ';

for i := 1 to b Step 1 do
RESULT := RESULT + mid(a, i,1) + ' ';
replace (RESULT, ' ', ' ')
 
As I said, it was only going to work if ({ARRFH.DOCDATE} was an actual date field. Is it possible that {ARRFH.DOCDATE} is a string rather than a date?

Try this:

Code:
WhilePrintingRecords;

Local StringVar a := {ARRFH.DOCDATE};
Local NumberVar b := Len(a);
Local NumberVar i;
Local StringVar RESULT := '';

for i := 1 to b Step 1 do
RESULT := RESULT + Mid(a, i,1) + ' ';

Replace(RESULT, '  ', ' ')

Cheers,
Pete.
 


Hi! I added pwformatdate and it worked!! thank you so much.


whilePrintingRecords;

Local StringVar a := ToText(pwformatdate({ARRFH.DOCDATE}),'MM dd yyyy');
Local Numbervar b :=Len(a);
Local Numbervar i;
Local Stringvar RESULT := ' ';

for i := 1 to b Step 1 do
RESULT := RESULT + mid(a, i,1) + ' ';
replace (RESULT, ' ', ' ')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top