How do I make an automatic week range?

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

How do I create a week range that auto populates every week.

So I am trying to get a field that shows a week range for example the week range for this week is 7/13-7/20

But I want it to be able to auto populate every week. So I don't have to enter it in.

Photo of Charles

Charles

  • 0 Points

Posted 4 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,316 Points 50k badge 2x thumb
Is there a date or date / time field that you are working off of that you want bucketed?
Photo of Charles

Charles

  • 0 Points
I am actually working of a text field. Cause its to complicated to even begin to use a date field.

So I just make a text choice for 7/13-7/20 and so on.
But I want it to know the week range automatically so I don't have to enter it every week.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,316 Points 50k badge 2x thumb
I understand that the result will be a text field. but what do we base the calculation on?  Does the record have a date field?
Photo of Charles

Charles

  • 0 Points
yes the record has a date field based on the next field I made. So its really bad. I didn't create this I am just trying to fix it!

So every week we have a new week range in which we base our work flow on. So I am trying to get a week range set up to where we don't have to click the text field and find the right week. I just want it to auto populate.

So I guess a ToMonth(Days(7))  or something like that.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,316 Points 50k badge 2x thumb
You need to basically construct the text part by part.  I zero padded the MM and DD for 1 digit months and years.

var date StartDate = FirstDayOfWeek([Date]) + Days(1);
var date EndDate = $StartDate+ Days(7);

var text StartMM = Right("0" & ToText(Month($StartDate)),2);
var text StartDD = Right("0" & ToText(Day($StartDate)),2);
var text StartYY = Right(ToText(Year($StartDate)),2);

var text EndMM = Right("0" & ToText(Month($EndDate)),2);
var text EndDD = Right("0" & ToText(Day($EndDate)),2);
var text EndYY = Right(ToText(Year($EndDate)),2);

List("/", $StartMM, $StartDD, $StartYY)
& " - "
& List("/", $EndMM, $EndDD, $EndYY)
Photo of Charles

Charles

  • 0 Points
I think that makes since.... Thank you.. Ill give it a go.