×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

date format spacing

date format spacing

date format spacing

(OP)


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.

RE: date format spacing

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.

RE: date format spacing

(OP)
Hi!

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


whilePrintingRecords;

Local StringVar a := ToText({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, ' ', ' ')

RE: date format spacing

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.

RE: date format spacing

(OP)


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, ' ', ' ')

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close