+ Reply to Thread
Results 1 to 10 of 10

Trying to Calculate day and night hours based on sunset and sunrise

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2007
    Posts
    14

    Trying to Calculate day and night hours based on sunset and sunrise

    I am a pilot and would like to create a lookup feature so that I do not always have to specify if a flight is day or night. I can enter all of the sun rise and sunset times from another source, I just need to figure out how to compare that with the times of my flight to determine if it was day or night, or some of both. I always have multiple legs on the same day, so the formula will have to know what date the flight was on to find the correct date for the sun rise and sunset times. I have posted an example day from the first of this month.
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: Trying to Calculate day and night hours based on sunset and sunrise

    try something like this...

    =IF(H2>C7,"Nighttime Departure","Daylight Departure")&" & "&IF(I2>C7,"NighttimeArrival","Daytime Arrival")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Trying to Calculate day and night hours based on sunset and sunrise

    where/how do you want the result to appear? do you need to take into account time zone changes or local/destination sunrise/set? some examples of this would help..
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  4. #4
    Forum Contributor Steve N.'s Avatar
    Join Date
    12-22-2011
    Location
    USA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    298

    Re: Trying to Calculate day and night hours based on sunset and sunrise

    This slight variation on Dibb's solution will give the sunrise result you need.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    =IF(OR(H2>$C$7,H2<$B$7),"Nighttime Departure","Daylight Departure")&" & "&IF(OR(I2>$C$7,I2<$B$7),"NighttimeArrival","Daytime Arrival")
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-06-2012
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Trying to Calculate day and night hours based on sunset and sunrise

    Here is an example of my logbook so that I can clarify what I am looking for a little more. I would like to be able to put in the Departure and arrival times and then it figure out the day time and night time from that.

    Currently the way that I do that is assume everything is day time, and then if I have some night flying I will enter that manually and my spreadsheet will subtract it from the day time.

    @dredwolf, It would be great to be able to include multiple locations and time zones, but right now I am just trying to figure out how to do it with one location and one time zone then I can try to expand it from there.
    Attached Files Attached Files

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: Trying to Calculate day and night hours based on sunset and sunrise

    test these and let me know how you make out...

    in J14 =IF(G14>=$C$7,0,IF(H14<=$C$7,H14-G14,$C$7-G14))
    in k14 =IF(G14>=$C$7,H14-G14,IF(H14<=$C$7,0,H14-$C$7))

  7. #7
    Registered User
    Join Date
    12-06-2012
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Trying to Calculate day and night hours based on sunset and sunrise

    FDibbins thanks for the starting formula. I was able to make it work for me after some modifications.

    The next thing that I would like to be able to do is use multiple locations in my formula. I was thinking that I will choose which ever one is closest to the change in daylight. Like if it is a morning flight or evening flight and we are still closest to the departure airport, then I would use those times. But if we are closer to the destination airport when the light changes then I would use that.

    I was thinking some sort of Vlookup, but I am not exactly sure how to make that work for me in this instance.

    Thanks.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    04-22-2014
    Location
    Lahore, Pakistan
    MS-Off Ver
    Excel 2013
    Posts
    1

    Re: Trying to Calculate day and night hours based on sunset and sunrise

    I am new member of your forum. I am also an airline pilot and my question is in continuation of davidhale87 to FDibbins for his reply which contains formulas,
    in J14 =IF(G14>=$C$7,0,IF(H14<=$C$7,H14-G14,$C$7-G14))
    in k14 =IF(G14>=$C$7,H14-G14,IF(H14<=$C$7,0,H14-$C$7)).
    I believe it works fine only if flight starts in the day time and ends at night. Now if the scenario is inverted like if the start time is at night and end time after sunrise how the calculation would be done. I must thank you for your previous help and will remain thankful for your help in future. I do appreciate Excel Forum also, thanks.

  9. #9
    Registered User
    Join Date
    07-27-2023
    Location
    Delhi
    MS-Off Ver
    MS Office 7
    Posts
    1

    Re: Trying to Calculate day and night hours based on sunset and sunrise

    Can anyone provide me an excel for calculating day and night flight time using sunrise and sunset

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,406

    Re: Trying to Calculate day and night hours based on sunset and sunrise

    Quote Originally Posted by Ashok2302 View Post
    Can anyone provide me an excel for calculating day and night flight time using sunrise and sunset
    Hello Ashok2302. Welcome to the forum.

    Since this thread is @ 10 and a half years old it is unlikely the original contributors are still following it.

    Also please familiarize yourself with our forum rules. There aren't many, and rule 4 addresses thread hijacking. You need to start your own thread. If this thread relates in some way with your own simply make reference to it in your thread.

    Thank you and again welcome to the forum.

    Dave
    Dave

+ 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