+ Reply to Thread
Results 1 to 4 of 4

Subtract # of days from date, but if not sat, goto previous sat?

  1. #1
    Fernando
    Guest

    Subtract # of days from date, but if not sat, goto previous sat?

    Need to calculate dates by subtracting a certain number of days, but if it is
    not a particular day of the week, it needs to go back to the previous week
    and give me the date of that particular day of the week.

  2. #2
    Tom Ogilvy
    Guest

    RE: Subtract # of days from date, but if not sat, goto previous sat?

    something like:

    =IF(WEEKDAY(TODAY()-B9,1) =
    3,TODAY()-B9,TODAY()-B9-(WEEKDAY(TODAY()-B9))-(7-3))

    B9 contains the number of days to subtract
    Where 3 represents Tuesday. Change to suit.

    --
    Regards,
    Tom Ogilvy


    "Fernando" wrote:

    > Need to calculate dates by subtracting a certain number of days, but if it is
    > not a particular day of the week, it needs to go back to the previous week
    > and give me the date of that particular day of the week.


  3. #3
    Fernando
    Guest

    RE: Subtract # of days from date, but if not sat, goto previous sa

    Tom,
    The formula works, but in some cases it would go back an extra week. For
    example I have to go back 28 days from 10/10/06 and make sure that it is a
    Sunday. If you subtract 28 days to Oct 10, you end up at Tue Sept 12th. If
    you have to go back to the closest Sunday, then the formula should give you
    Sun Sept 10th, but it is giving me Sun Sept 03. The funny thing is that
    works for some days, but for other do not work. Can you help me?

    Fernando


    "Tom Ogilvy" wrote:

    > something like:
    >
    > =IF(WEEKDAY(TODAY()-B9,1) =
    > 3,TODAY()-B9,TODAY()-B9-(WEEKDAY(TODAY()-B9))-(7-3))
    >
    > B9 contains the number of days to subtract
    > Where 3 represents Tuesday. Change to suit.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Fernando" wrote:
    >
    > > Need to calculate dates by subtracting a certain number of days, but if it is
    > > not a particular day of the week, it needs to go back to the previous week
    > > and give me the date of that particular day of the week.


  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Hi Fernando, try this formula, again B9 is the number of days to subtract but the 2 represents Tuesday (0=sun through to 6 =sat)

    =TODAY()-B9-WEEKDAY(TODAY()-B9-2)+1

    so if you always want to find a Sunday it's just

    =TODAY()-B9-WEEKDAY(TODAY()-B9)+1

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1