+ Reply to Thread
Results 1 to 7 of 7

Excel 2007 : today()-2 working days, in with other text

  1. #1
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    today()-2 working days, in with other text

    Hi,

    I have the following formula at present:

    ="ComplianceTracker for 2 days prior: ie"&" "&TEXT(TODAY(),"ddd dd-mmm")&" "&"checking for"&" "&TEXT(TODAY()-2,"ddd dd-mmm")

    Which currently shows the following:

    ComplianceTracker for 2 days prior: ie Thu 12-May checking for Tue 10-May

    However I ony want to count dates that fall Mon-Fri. So:
    If today() is a Mon, it should show Thursdays date
    If today() is a tuesday, it should show Friday
    Then if today() is Wednesday, it should show Monday.

    I've tried integrating the WORKDAY function in several places, but nothing seems to work.

    Thanks in advance.
    Last edited by dancing-shadow; 05-12-2011 at 05:06 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,502

    Re: today()-2 working days, in with other text

    One way, maybe:

    ="ComplianceTracker for 2 days prior: ie"&" "&TEXT(TODAY(),"ddd dd-mmm")&" "&"checking for"&" "&TEXT(IF(WEEKDAY(TODAY())>3,TODAY()-2,TODAY()-4),"ddd dd-mmm")


    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: today()-2 working days, in with other text

    What if TODAY is sunday?
    Never use Merged Cells in Excel

  4. #4
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: today()-2 working days, in with other text

    Quote Originally Posted by TMShucks View Post
    One way, maybe:

    ="ComplianceTracker for 2 days prior: ie"&" "&TEXT(TODAY(),"ddd dd-mmm")&" "&"checking for"&" "&TEXT(IF(WEEKDAY(TODAY())>3,TODAY()-2,TODAY()-4),"ddd dd-mmm")


    Regards
    That looks to work (still testing on my sheet), but I don't quite understand the highlighted part. I get that it says something about 'if today ??' then today-2, otherwise today-4', but I'd like to understand the ?? part so I can edit myself if needed.

    Many thanks.

  5. #5
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: today()-2 working days, in with other text

    Quote Originally Posted by zbor View Post
    What if TODAY is sunday?
    Today will never = sunday, as I only use this file at work, and only work mon-friday

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,502

    Re: today()-2 working days, in with other text

    It's part of an IF statement:

    TEXT ... (IF(WEEKDAY(TODAY())>3,TODAY()-2,TODAY()-4))

    It's checking what weekday it is and adjusting the date appropriately


    You can test using a cell rather than TODAY()

    ="ComplianceTracker for 2 days prior: ie"&" "&TEXT(B3,"ddd dd-mmm")&" "&"checking for"&" "&TEXT(IF(WEEKDAY(B3)>3,B3-2,B3-4),"ddd dd-mmm")

    If B3 has 02/05/2011, you get:

    ComplianceTracker for 2 days prior: ie Mon 02-May checking for Thu 28-Apr


    Regards

  7. #7
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: today()-2 working days, in with other text

    Quote Originally Posted by TMShucks View Post
    It's part of an IF statement:

    TEXT ... (IF(WEEKDAY(TODAY())>3,TODAY()-2,TODAY()-4))

    It's checking what weekday it is and adjusting the date appropriately


    You can test using a cell rather than TODAY()

    ="ComplianceTracker for 2 days prior: ie"&" "&TEXT(B3,"ddd dd-mmm")&" "&"checking for"&" "&TEXT(IF(WEEKDAY(B3)>3,B3-2,B3-4),"ddd dd-mmm")

    If B3 has 02/05/2011, you get:

    ComplianceTracker for 2 days prior: ie Mon 02-May checking for Thu 28-Apr


    Regards

    That works brilliantly - many thanks

+ 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