Results 1 to 6 of 6

Thread: Difference between 2 dates applications

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    50

    Difference between 2 dates applications

    Hello,

    This is quite an awkward problem to describe, but bear with me...

    I have a spreadsheet, including 2 columns. Let's say column A has the header Priority, and Column B has the header Due Date.

    The user will assign an initial numeric value to Priority and assign a Due Date, for a given project. A higher number in the Priority column indicates a higher priority.

    This is where the complication comes. Is there a way to increase the value in the Priority box by, say 50, for every week closer to the Due Date we get, based on the date today.

    I don't know whether this needs to be VBA or if there is just a simple formula you can enter into a cell. Either way, I'm stumped.

    Thanks in advance.

  2. #2

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    50

    Re: Difference between 2 dates applications

    To perhaps make this a little clearer, the user enters the following:

    Priority
    100

    Due Date
    01/03/2012

    The date today is 09/02/2012.

    In one week, ie 16/02/2012, the Priority value increases to 150.
    In 2 weeks, ie 23/02/2012, the Priority value increases to 200. etc

    Also, is there a way to stop the Priority value increasing, once the Due Date has been reached.

    Thanks.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Difference between 2 dates applications

    In one week, ie 16/02/2012, the Priority value increases to 150.
    In 2 weeks, ie 23/02/2012, the Priority value increases to 200. etc
    this contradicts you first post

    i would have a maximum priority then decrease for each extra week
    example max of 500 less 50 for each week zeroes out in 10 weeks
    try something like
    vb Code:
    1. weeks = DateDiff("w", Date, Cells(rw, 2)) + 1
    2. Cells(rw, 1) = 500 * (10 - weeks) * 0.1
    3. If DateDiff("d", Date, Cells(rw, 2)) = 0 Then Cells(rw, 1) = "too late"
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    50

    Re: Difference between 2 dates applications

    I see your point, but unfortunately, this is part of a project for someone else. They have been using this priority system for a while, and it is up to me to find a more automated version. I think they would be quite apprehensive if I were to change the way they prioritise everything. Is there no way to implement the slightly more awkward process that I first suggested?

  5. #5
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Difference between 2 dates applications

    You would need more data to do such a calculation.
    The Input-Date and the Initial Priority are needed, having them you can calculate the Actual Priority.
    Code:
    Weeks = DateDiff("w", Date, InputDate))  
    Actual Priority=Weeks*100 + Initial Priority
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Difference between 2 dates applications

    more awkward process that I first suggested?
    you did not give enough information to provide a calculation of priorities based on your example
    need starting values etc.
    still you should be able to manage a calculation or a select case of the number of weeks
    vb Code:
    1. select case weeks
    2.   case 1: cells(rw, 1) = 450
    3.   case 2: cells(rw, 1) = 400
    4.   case 3: cells(rw, 1) = 350
    5.   ' etc
    6. end select
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width