Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-mini-2024-07-18· OpenAIAi2 WildChat-4.8M (AI2)

If the date in $C20 is less than Today and the date in $B20 is greater than Today - 1

  1. User

    If the date in C20islessthanTodayandthedateinC20 is less than Today and the date in B20 is greater than Today - 1

  2. Assistant

    To create a formula in Excel that checks if the date in cell C20 is less than today and the date in cell B20 is greater than yesterday, you can use the following formula:

    =AND(C20 < TODAY(), B20 > TODAY() - 1)
    

    Explanation:

    • TODAY() returns the current date.
    • C20 < TODAY() checks if the date in cell C20 is earlier than today.
    • B20 > TODAY() - 1 checks if the date in cell B20 is later than yesterday (which is equivalent to today - 1).
    • AND(...) ensures that both conditions must be true for the entire formula to return TRUE.

    Make sure that both C20 and B20 actually contain date values for the formula to work correctly.

  3. User

    what does this formula do: =IFERROR(DATE(YEAR(TODAY()), VALUE(MID(F33, FIND("/", F33) + 1, 2)), VALUE(LEFT(F33, FIND("/", F33) - 1))),"")

  4. Assistant

    The formula you've provided is:

    =IFERROR(DATE(YEAR(TODAY()), VALUE(MID(F33, FIND("/", F33) + 1, 2)), VALUE(LEFT(F33, FIND("/", F33) - 1))),"")
    

    Breaking it down:

    1. FIND("/", F33):

      • This finds the position of the first "/" character in the string contained in cell F33.
    2. MID(F33, FIND("/", F33) + 1, 2):

      • This extracts a substring from the text in F33. It starts right after the "/" (hence the + 1), and takes 2 characters from that position. This is typically used to get the month from a date formatted as "DD/MM" or "MM/DD".
    3. LEFT(F33, FIND("/", F33) - 1):

      • This retrieves everything to the left of the first "/" in F33, effectively extracting the day (if the format is "DD/MM" or "MM/DD").
    4. VALUE(...):

      • The VALUE function converts the extracted text values into numbers. This is important because dates need to be represented as numbers in Excel.
    5. DATE(YEAR(TODAY()), ..., ...):

      • This constructs a valid date using the current year (retrieved with YEAR(TODAY())) along with the month and day values obtained from the previous steps.
    6. IFERROR(..., ""):

      • This handles any potential errors that may arise during the execution of the formula (e.g., if F33 does not contain a valid date format). If there is an error, it returns an empty string ("") instead of an error message.

    Overall function:

    The entire formula takes a date string from cell F33, which is expected to be in a format like "DD/MM" or "MM/DD", extracts the day and month, and combines them with the current year to create a date. If the extraction process fails (and thus generates an error), it returns an empty string instead of an error.

    Example:

    • If F33 contains "12/09", the formula will produce the date September 12 of the current year.
    • If F33 contains "Invalid", the formula will return an empty string.
  5. User

    The formula is showing me the first date (28/10) in the text string. I want the formula to show me the second date (31/10) in thhis text string: 28/10 to 31/10 - Robert Reading - on leavev for 5 days

  6. Assistant

    To extract the second date (31/10) from a text string like "28/10 to 31/10 - Robert Reading - on leave for 5 days", you can modify the formula to specifically target the second date. Here's how you can do it:

    Assuming the text string is in cell F33, you can use the following formula:

    =IFERROR(DATE(YEAR(TODAY()), VALUE(MID(F33, FIND("to", F33) + 3, 2)), VALUE(MID(F33, FIND("to", F33) + 1, 2))), "")
    

    Explanation of the Formula:

    1. FIND("to", F33): This finds the position of the word "to" in the text string, which precedes the second date.

    2. MID(F33, FIND("to", F33) + 3, 2):

      • This extracts the second date's day (the two characters after the "to ").
      • The + 3 skips over the "to " (2 characters + 1 space).
    3. MID(F33, FIND("to", F33) + 1, 2):

      • This would incorrectly pull the first date again, hence it should be removed.
    4. Using VALUE(...):

      • The VALUE function will convert the text representation of day and month into numbers for the DATE function.
    5. DATE(YEAR(TODAY()), ..., ...):

      • This constructs a date using the current year, and the extracted month (which we need to specify) and the day (31 in your case).
    6. IFERROR(..., ""):

      • If any part of the extraction fails, this will output an empty string instead of generating an error.

    Final Correct Formula

    Assuming you're extracting the month from October (which is 10), you can specify it directly in the formula:

    =IFERROR(DATE(YEAR(TODAY()), 10, VALUE(MID(F33, FIND("to", F33) + 3, 2))), "")
    

    Summary:

    This formula will extract the second date "31" from the string in F33, combine it with the current year and the month of October (10) to produce the date of October 31 of the current year. If there's an issue in extraction, it will return an empty string.

  7. User

    it is not showing the date

  8. Assistant

    Let's refine the approach to ensure we correctly extract the second date (31/10) from the text string "28/10 to 31/10 - Robert Reading - on leave for 5 days" in cell F33.

    To structure the formula correctly, we need to follow these steps:

    1. Find the position of "to" in the string to help locate the second date.
    2. Extract the second date's day and month.
    3. Construct a full date using the extracted information, ensuring it handles the correct year.

    Here's the correct formula:

    =IFERROR(DATE(YEAR(TODAY()), VALUE(MID(F33, FIND("/", F33, FIND("to", F33)) - 2, 2)), VALUE(MID(F33, FIND("to", F33) + 3, 2))), "")
    

    Explanation of the Formula:

    1. FIND("to", F33): This finds the starting position of the keyword "to".
    2. FIND("/", F33, FIND("to", F33)): This finds the position of the first "/" after "to", which helps us locate the second date.
    3. MID(F33, FIND("/", F33, FIND("to", F33)) - 2, 2): This extracts the month from the second date. It goes back 2 characters from the position of "/".
    4. MID(F33, FIND("to", F33) + 3, 2): This extracts the day following "to " and the space, pulling in the subsequent two characters for the day of the second date.
    5. DATE(YEAR(TODAY()), ..., ...): This constructs a date using the current year along with the extracted month and day.
    6. IFERROR(..., ""): If any part of the extraction fails, this will output an empty string instead of generating an error.

    How It Works:

    Assuming the text is in cell F33:

    • The formula identifies that "31/10" is the portion that is needed.
    • It constructs a valid date (October 31 of the current year) from these extracted values.

    Example

    Using the string in F33:

    • Input: "28/10 to 31/10 - Robert Reading - on leave for 5 days"
    • Output of the formula: Returns October 31 of the current year as a date.

    Make sure that your cell format is set to display the result as a date (not as text), so you can see the output correctly. Also, please confirm that the text exactly matches the expected format, as any deviation will affect the formula's ability to correctly parse it.

  9. User

    It worked

  10. Assistant

    Great to hear that it worked! If you have any more questions or need further assistance with Excel formulas or anything else, feel free to ask. Happy spreadsheeting!