+ Reply to Thread
Results 1 to 17 of 17

Day Calculation from any date to any date

  1. #1
    Registered User
    Join Date
    01-30-2019
    Location
    Lagos
    MS-Off Ver
    10
    Posts
    9

    Day Calculation from any date to any date

    Hi,

    I have my passport stamped in and stamped out date for the last 3 years, and I want to know how many days was I in country or out of country from any date to any date.
    For example, my query will be from 1st july to 31st june, how many days was I out of country.
    I am attaching the excel sheet.
    Thanks in advance for the help.
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,426

    Re: Day Calculation from any date to any date

    Put this in D3:

    =IF(OR(B3="",C3=""),0,C3-B3)

    Format the cell as General or as Number, then copy down.

    Hope this helps.

    Pete

  3. #3
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,494

    Re: Day Calculation from any date to any date

    Dates in excel are stored as numbers so you can simple substract one date from another as long as it does not result in negative numbers

    so a simple =C3-B3 will result in 92 days.

    see also attached sheet.

    just as FYI: time are fractions of 1 so if stamps would also have a time you could even calculate the days and hours spend in a country.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-30-2019
    Location
    Lagos
    MS-Off Ver
    10
    Posts
    9

    Re: Day Calculation from any date to any date

    Thanks for the help, Pete.
    I need to get this info from a particular date to a particular date, and not just the days in between.
    Please, I want to put in 2 dates, and need the calculation of days in country between those dates.
    Hope I made myself clearer now.
    Sudeepta

  5. #5
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,494

    Re: Day Calculation from any date to any date

    So you want to know the days between stamp in 13-4-2016(cell C3) and 26-6-2016 (Cell B4)?

    that is simular only just not take the dates from the same line.. To get a good result always start with newest date. so in this case =B4-C3 will get you 74 days in India. you may want to add +1 if you want to count the day in as day in the country.

  6. #6
    Registered User
    Join Date
    01-30-2019
    Location
    Lagos
    MS-Off Ver
    10
    Posts
    9

    Re: Day Calculation from any date to any date

    Hi Roel,

    I want days between random dates ex. how many days was I out from 1/1/2017 to 31/7/2017?

    Thanks

  7. #7
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,494

    Re: Day Calculation from any date to any date

    I'm sorry, now you lost me.. what is the purpose of a table example? how are the random dates determined then?
    the calculation is very easy as you can see. substract oldest date from the newest and you get days.

    I really do not get what you mean by days between random dates..

  8. #8
    Registered User
    Join Date
    01-30-2019
    Location
    Lagos
    MS-Off Ver
    10
    Posts
    9

    Re: Day Calculation from any date to any date

    The dates are actual dates of arrival/departure, and I want to generate year wise breakup of how many days in country.

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,426

    Re: Day Calculation from any date to any date

    If you are only interested in whole years, use D1 to record the year of interest (e.g. 2017), then you can use this formula in cell D3:

    =IF(OR(B3="",C3=""),0,IF(OR(C3 < DATE(D$1,1,1),B3 > DATE(D$1+1,1,0)),0,IF(AND(B3 < =DATE(D$1+1,1,1),C3 > =DATE(D$1+1,1,1)),DATE(D$1+1,1,1),C3)-IF(AND(B3 < DATE(D$1,1,1),C3 > =DATE(D$1,1,1)),DATE(D$1,1,1),B3)))

    Copy down as required.

    Note that I have had to introduce spaces around < and > to get past the firewall.

    Hope this helps.

    Pete

  10. #10
    Registered User
    Join Date
    01-30-2019
    Location
    Lagos
    MS-Off Ver
    10
    Posts
    9

    Re: Day Calculation from any date to any date

    Thanks a lot Pete, unfortunately, this did not work even as I removed the spaces as you said.
    Is there any way I can have 2 cells to put in from day and to day, and then the calculation is done.
    Hope I get a solution to this soon,
    Thanks

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,426

    Re: Day Calculation from any date to any date

    Okay, see attached file.

    I've used C1 for the start date and E1 for the end date, and this formula in D3:

    =IF(OR(B3="",C3=""),0,IF(OR(C3<C$1,B3>E$1),0,IF(AND(B3<=E$1,C3>=E$1),E$1,C3)-IF(AND(B3<C$1,C3>=C$1),C$1,B3)))

    This time the firewall let it through, without extra spaces.

    Hope this helps.

    Pete
    Attached Files Attached Files
    Last edited by Pete_UK; 01-30-2019 at 02:47 PM.

  12. #12
    Registered User
    Join Date
    01-30-2019
    Location
    Lagos
    MS-Off Ver
    10
    Posts
    9

    Re: Day Calculation from any date to any date

    Hi Pete,
    Thanks for the effort you are putting in, your answer helped me frame the question better and clearer, I guess.
    Please see the attached, I want excel to calculate me this, I know you can do it.
    Thanks.
    Attached Files Attached Files

  13. #13
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,426

    Re: Day Calculation from any date to any date

    Well, I might be able to do it, but I'm just about to go out now, so I'll take a more detailed look later on when I get back.

    Pete

  14. #14
    Registered User
    Join Date
    01-30-2019
    Location
    Lagos
    MS-Off Ver
    10
    Posts
    9

    Re: Day Calculation from any date to any date

    Sure,
    shall be waiting for your reply.
    Thanks.

  15. #15
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Day Calculation from any date to any date

    Try this:

    One horrendous IF statement:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    See the attached workbook
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    01-30-2019
    Location
    Lagos
    MS-Off Ver
    10
    Posts
    9

    Re: Day Calculation from any date to any date

    Hi Pete,

    Thanks a lot!! Looks like this Horrendous "IF" statement is indeed working. There is a small challenge with the days in India, but that is minor one.
    Shall get back once I go through the same and use it a couple of times.
    Did I mention You are GOOD at this?

    Best regards

  17. #17
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,426

    Re: Day Calculation from any date to any date

    That last one was from Geoff, but it does the same job as mine from Post #11, although in a different way.

    Pete

+ 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. RE: date calculation, no date displays for blank adjacent cell
    By kittycrickett in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-11-2015, 10:55 AM
  2. Long date/short date conversion and cycle time calculation
    By COGICPENNY in forum Excel General
    Replies: 1
    Last Post: 02-14-2014, 05:17 PM
  3. [SOLVED] If Statement with today's date minus due date for a delay calculation
    By RDFUC in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2013, 02:58 PM
  4. [SOLVED] Need Calculation - If A1=Annual, Anniv. Date for Current Year, else Biennial Date
    By TaxAnnihilator in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-11-2013, 06:06 PM
  5. Replies: 4
    Last Post: 06-02-2012, 11:26 AM
  6. Replies: 1
    Last Post: 04-18-2012, 05:49 PM
  7. subtract a delivery date:Date Calculation to exclude weekends
    By Vim in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-24-2006, 11:00 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