+ Reply to Thread
Results 1 to 16 of 16

Formula to get a schedule date and time based on a warranty date

  1. #1
    Registered User
    Join Date
    01-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013, 2016
    Posts
    95

    Formula to get a schedule date and time based on a warranty date

    Hi all,

    Based on a warranty date, I would like to

    Set a Date and Time
    Date should be at least 2 days before the warranty expiration date.
    If warranty date is a Monday, date should be at least Wednesday from previous week @ 10 am or 2 pm
    Days must only be Monday, Tuesday, Wednesday
    Unique date and time (Incorrect Highlighted in yellow)
    Time should be 10 am and 2 pm (not sure how to automate this one)
    Date & Time Format: dd-MM-yyyy hh:mm:ss

    Example:

    Warranty date Thursday 12-04-2018 -> Result: 09-04-2018 10:00:00 (Monday)
    Warranty date Thursday 12-04-2018-> Result: 09-04-2018 14:00:00 (Monday)
    Warranty date Monday 07-05-2018-> Result: 02-05-2018 10:00:00 (Wednesday)
    Warranty date Monday 07-05-2018-> Result: 02-05-2018 14:00:00 (Wednesday)

    I come up with following formula but I am stuck to get a correct formula with several dates (see XL sheet attached)
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by dude6571; 03-10-2018 at 04:49 AM.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formula to get a schedule date and time based on a warranty date

    See attached workbook

    - formulas below pictue

    .
    Warranty.jpg
    .

    C2 - with custom format dd/mm/yyyy hh:mm
    =B2+(A2/24)

    E2
    =IF(OR(WEEKDAY(C2)=4,WEEKDAY(C2)=5,WEEKDAY(C2)=6),C2-2,C2-WEEKDAY(C2)-3) - see correction in next post

    F2 - with custom format dddd
    =TEXT(E2,"DDDD")

    G2 - with custom format hh:mm
    =E2

    Explanation of date and time
    A date is an integer eg today, 10 March 2018 = 43169
    A time is part of a day so noon = 12hours divided by 24 hours in day =12/24 = 0.5
    0.5 is noon on any day
    But if date and time are combined it becomes specific to one paricular day
    43169 + 0.5 = 43169.5 = 10 March 2018 12:00


    EDIT
    Looking at the picture, I can see that the formula sometimes gives the wrong Wednesday - formula updated in post#3
    Attached Files Attached Files
    Last edited by kev_; 03-10-2018 at 06:18 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formula to get a schedule date and time based on a warranty date

    The correct formula in E2

    =IF(OR(WEEKDAY(C2)=4,WEEKDAY(C2)=5,WEEKDAY(C2)=6),C2-2,IF(WEEKDAY(C2)=7,C2-WEEKDAY(C2)+4,C2-WEEKDAY(C2)-3))

    This is necessary because to Excel Saturday is day 7 and Sunday is day 1
    (it is confusing because most of us think that Monday is the 1st day of the week!)

    Warranty.jpg
    Last edited by kev_; 03-10-2018 at 06:25 AM.

  4. #4
    Registered User
    Join Date
    01-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013, 2016
    Posts
    95

    Re: Formula to get a schedule date and time based on a warranty date

    Hi Kev,

    Thank you for your input.

    Is there any way to adjust the formula to remove duplicate dates?

  5. #5
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formula to get a schedule date and time based on a warranty date

    Do you want each date and time combo to appear once only?

  6. #6
    Registered User
    Join Date
    01-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013, 2016
    Posts
    95

    Re: Formula to get a schedule date and time based on a warranty date

    Based on my screenshot, the highlighted yellow part show 2 similar dates

    29-05-2018 14:00:00 Tuesday

    I'd rather have 1 date as

    29-05-2018 14:00:00 Tuesday

    and then another one the next day

    30-05-2018 10:00:00 Wednesday

    Is it possible?

  7. #7
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formula to get a schedule date and time based on a warranty date

    Is column H what you want?
    Formula H2 copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    .
    Warranty once only.jpg

    .

    If not please repost my workbook with expected results in column J
    thanks
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013, 2016
    Posts
    95

    Re: Formula to get a schedule date and time based on a warranty date

    Hi Kev_

    Please find expected results in colum J in your workbook.

    For your info, I also have attached my work book.

    Cheers
    Attached Images Attached Images
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formula to get a schedule date and time based on a warranty date

    Everything matches your picture
    .

    EverythingMatchesUp.jpg

    .

    Formula in E2 copied down
    =C2-IF(OR(WEEKDAY(C2)=4,WEEKDAY(C2)=5,WEEKDAY(C2)=6),2,IF(WEEKDAY(C2)=3,6,5))

    Conditional formatting to make cell value invisible (it is there, you simply cannot see it)
    condition is:
    =COUNTIF($E$2:$E2,$E2)<>1
    and font colour set the same as background

    .

    Conditional Formatting with countif.jpg

    .
    example workbook attached
    Attached Files Attached Files
    Last edited by kev_; 03-11-2018 at 08:48 AM.

  10. #10
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formula to get a schedule date and time based on a warranty date

    I hope post#9 gave you the results you wanted

    Here is a more succinct formula in E2 copied down
    =C2-CHOOSE(WEEKDAY(C2),5,5,6,2,2,2,5)

    Explanation
    CHOOSE is multiple IF
    IF WEEKDAY(C2) = 1 or 2 or 3 .....

    WEEKDAY(C2) can be any value from 1 to 7

    1 subtract 5
    2 subtract 5
    3 subtract 6
    4 subtract 2
    5 subtract 2
    6 subtract 2
    7 subtract 5
    Last edited by kev_; 03-11-2018 at 09:04 AM.

  11. #11
    Registered User
    Join Date
    01-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013, 2016
    Posts
    95

    Re: Formula to get a schedule date and time based on a warranty date

    Thank you for your time Kev_ on my request.

    I went through the warranty date in my workbook (Post#8: Schedule_2018-2019.xlsx‎) and notice that I have 92 devices with same warranty date.
    Your formula works very well up to 6 devices with same warranty dates.

    Is VBA code required for the 92 devices with same warranty dates ?

  12. #12
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formula to get a schedule date and time based on a warranty date

    Your formula works very well up to 6 devices with same warranty dates.
    which formula?
    - is this conditional formatting?
    - VBA will not be required (one of the ranges needs changing to match the size of your real data)

  13. #13
    Registered User
    Join Date
    01-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013, 2016
    Posts
    95

    Re: Formula to get a schedule date and time based on a warranty date

    oops, please allow me to rephrase, this is conditionnal formatting.

    one of the ranges needs changing to match the size of your real data
    How do I do that, please?
    Last edited by dude6571; 03-12-2018 at 03:00 AM.

  14. #14
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formula to get a schedule date and time based on a warranty date

    The easiest way is to apply conditional formatting to whole columns
    - then it does not matter how may items there are

    Select the relevant columns and then select conditional formatting

    The formula in conditional formatting needs to be generated to work for the top-left cell of any range that it is applied to
    - so I amended my original formula to start at row 1 instead of row 2
    =COUNTIF($E$1:$E1,$E1)<>1 (where column E is the column containing date & time values)
    .

    cf whole column.jpg

  15. #15
    Registered User
    Join Date
    01-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013, 2016
    Posts
    95

    Re: Formula to get a schedule date and time based on a warranty date

    Thank you so much Kev_ for your help and patience.

    Highly appreciated

  16. #16
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formula to get a schedule date and time based on a warranty date

    Glad to help.
    Thanks for marking thread SOLVED and for rep

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Calculate warranty expiry date
    By bongielondy in forum Excel General
    Replies: 6
    Last Post: 08-02-2017, 10:11 AM
  2. Replies: 5
    Last Post: 12-01-2015, 02:36 PM
  3. Replies: 3
    Last Post: 08-31-2014, 06:39 AM
  4. [SOLVED] Calculate time remaining based on end date & time and current date
    By Kaz09 in forum Excel Formulas & Functions
    Replies: 33
    Last Post: 08-19-2014, 07:11 AM
  5. Replies: 3
    Last Post: 12-19-2013, 06:49 AM
  6. Replies: 0
    Last Post: 07-17-2012, 10:11 AM
  7. Date & time auto generated based on input date & time
    By BlastRanger in forum Excel General
    Replies: 18
    Last Post: 09-08-2010, 03:54 AM

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