How can I add week ending dates when I have only days of the week?

Options

Hello,

I need to display my starts and ends by week ending dates, but my report only has the start and end daily dates. I added a web form with week ending dates to match the start dates, and then joined the data, which did work, but not sure how to do the same with the actual end date.

image.png

Best Answers

  • ArborRose
    ArborRose Coach
    Answer ✓

    Using what I showed. If the week ends on Sunday, the formulas change to

    DATE_ADD(`StartDate`, CASE WHEN WEEKDAY(`StartDate`) = 1 THEN 0 ELSE 8 - WEEKDAY(`StartDate`) END)

    DATE_ADD(`ActualEndDate`, CASE WHEN WEEKDAY(`ActualEndDate`) = 1 THEN 0 ELSE 8 - WEEKDAY(`ActualEndDate`) END)

    I don't have raw detail records to match your aggregated output. But the aggregate totals should work if your data formula correctly gives Sunday.

    Let's say I have a dataset with a bunch of start dates that are all from 12/30/24 through 1/5/25. They should all come out to 1/5/25 as the week end date. And then aggregate the counts to get an output like you show.

    image.png

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • ColemenWilson
    Answer ✓

    @ArborRose it can definitely be done in a beastmode, the solution I provided uses a modulus which only works in Magic ETL formulas, not in beastmodes for some reason. That is why I said to use ETL if using my solution.

    If I solved your problem, please select "yes" above

Answers

  • ColemenWilson
    edited July 2

    Try:

    DATE_ADD(date, INTERVAL (7 - WEEKDAY(date)) % 7 DAY)

    This will not work in a beastmode, you'll have to use the formula tile in Magic ETL

    If I solved your problem, please select "yes" above

  • Add this in ETL or beast mode?

  • ETL. Won't work in beastmode

    If I solved your problem, please select "yes" above

  • And sorry, I typed it wrong, it should be:
    DATE_ADD(date, INTERVAL (1 - DAYOFWEEK(date) + 7) % 7 DAY)

    If I solved your problem, please select "yes" above

  • Assuming you want Saturday is your last day of the week, this would get you that date. And this would work in a beast mode or ETL.


    1. DATE_ADD
      (`dt`, INTERVAL (7- DAYOFWEEK(`dt`)) DAY)

    See this excellent post by @GrantSmith for other first and last functionality.

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.
  • Nothing wrong with Colemen's formula, but since you already created a table that you joined on your start dates, you should be able to use that same table and join it a second time to your end dates.

    Also, for a BeastMode friendly formula approach, you could leverage the WEEKDAY function, which returns 1 for Sunday, 2 for Monday, etc, so 7 minus the Weekday is the number of days until the end of the week.

    date(Date + (7 - WEEKDAY(Date)))

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.

    Please accept the answer if it solved your problem.

  • Why can't you do it on a card?

    image.png image.png image.png
    CompanyName,PositionDateCreated,DateFilled,StartDate,EstimatedEndDate,ActualEndDate,LastDateWorked
    Company A,2014-02-25,2014-02-25,2014-03-07,2024-01-01,,2025-05-14
    Company B,2014-05-21,2014-05-21,2014-05-19,2025-07-27,,2025-06-15
    Company C,2014-09-17,2014-09-17,2014-09-15,2025-03-31,2025-03-31,2025-03-31
    Company D,2015-07-30,2015-08-14,2015-08-24,2025-12-31,,2025-06-27
    Company E,2017-02-24,2017-04-18,2017-04-20,2025-06-27,,2025-06-27
    Company F,2017-12-19,2017-12-20,2017-12-21,2025-07-06,,2025-06-29
    Company G,2018-02-12,2018-02-13,2018-02-14,2025-10-05,,2025-06-27
    Company H,2018-04-05,2018-04-09,2018-04-16,2025-08-31,,2025-06-26
    Company I,2018-06-15,2018-06-15,2018-06-12,2025-03-16,,2025-06-25
    Company J,2018-10-05,2018-10-05,2018-10-02,2025-05-23,,2025-06-28
    Company K,2018-10-10,2018-10-17,2018-10-18,2024-01-01,,2025-06-28
    Company L,2019-01-22,2019-01-22,2019-01-01,2025-11-30,,2025-06-27
    Company M,2019-09-19,2019-09-26,2019-09-26,2025-08-26,,2025-06-27
    Company N,2019-10-18,2019-10-18,2019-10-29,2025-05-02,2025-03-21,2025-03-21

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • Thank you for all the replies. My week ending date is Sunday, and below is what my starts by week look like. I am having an issue with displaying the same as ends.

    image.png
  • ArborRose
    ArborRose Coach
    Answer ✓

    Using what I showed. If the week ends on Sunday, the formulas change to

    DATE_ADD(`StartDate`, CASE WHEN WEEKDAY(`StartDate`) = 1 THEN 0 ELSE 8 - WEEKDAY(`StartDate`) END)

    DATE_ADD(`ActualEndDate`, CASE WHEN WEEKDAY(`ActualEndDate`) = 1 THEN 0 ELSE 8 - WEEKDAY(`ActualEndDate`) END)

    I don't have raw detail records to match your aggregated output. But the aggregate totals should work if your data formula correctly gives Sunday.

    Let's say I have a dataset with a bunch of start dates that are all from 12/30/24 through 1/5/25. They should all come out to 1/5/25 as the week end date. And then aggregate the counts to get an output like you show.

    image.png

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • ColemenWilson
    Answer ✓

    @ArborRose it can definitely be done in a beastmode, the solution I provided uses a modulus which only works in Magic ETL formulas, not in beastmodes for some reason. That is why I said to use ETL if using my solution.

    If I solved your problem, please select "yes" above

  • ArborRose
    ArborRose Coach
    edited July 2

    @ColemenWilson I'm not smart enough for that fancy math. I have to use fingers and toes.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • I appreciate all the help, and I am good now. I am using the beast mode, but I will also try the ETL. Thank you again!