Copy link to clipboard
Copied
Hi!
I set up 7 fields:
FIELD02, FIELD03, FIELD04, FIELD05, FIELD06, FIELD07, FIELD08
to automatically populate with the days of the week:
SU, MO, TU, WE, TH, FR, SA
based on the user's entry in FIELD01, which is a "week ending date" formatted as "Date" and "mm/dd/yyyy".
I put the following formula into the 7 fields, with the -6 changing to -5, -4, -3, -2, -1, -0 for each field:
var s = this.getField("FIELD01").valueAsString;
if (s=="") event.value = "";
else {
var d = util.scand("mm/dd/yyyy", s);
d.setDate(d.getDate()-6);
event.value = util.printd("ddd", d);
}
Success, it worked! Except that the days of the week are displaying as:
Sun
Mon
Tue
Wed
Thu
Fri
Sat
Is there a way to make the auto-entries be 2 characters and all upper-case (SU, MO, TU, etc.)? I'm guessing it's the "ddd" that's doing it and I don't know if there's something to use in its place ("DD" didn't work). Or if it must be 3 characters can they all be upper-case?
Thank you so much! You all are so awesome in your help here!
Diane
Copy link to clipboard
Copied
It's a simple string manipulation:
event.value = util.printd("ddd", d).substring(0,2).toUpperCase();
Copy link to clipboard
Copied
It's a simple string manipulation:
event.value = util.printd("ddd", d).substring(0,2).toUpperCase();
Copy link to clipboard
Copied
Thank you, try67! To my rescue again! 🙂
After seeing the "simple" string manipulation 😉 that's needed I'm picturing a meme where someone has accidentally spit-sprayed their drink out over something they just read - in this case my simpler yet failed solution of using "DD". I can imagine that some posts might make members here chuckle (or spit-spray their drinks out).
I truly do appreciate your help here and your time spent doing it.
Have a wonderful day!
Diane
Copy link to clipboard
Copied
I guess "simple" is a relative term... :=)
Anyway, you were not far off, but you didn't know that "dd" returns the full date in numbers, not in letters.
For future reference, "d" returns the short date in digits (without zero for values smaller than 10), "dd" returns the full date in two digits, "ddd" returns an abbreviated name (using the first three letters, in English), and "dddd" returns the full name.
But once you have that name you can manipulate it regardless of the options the printd method provides.
Copy link to clipboard
Copied
lol, right? I thought "Simple? Hmm, okay, first I need to figure what 'simple string manipulation' even means..." lol
Thank you so much for the additional information regarding the date formats I can use!
Have a great day!
Diane