How to Calculate Sunrise Sunset
Find sunrise and sunset times for any location and date.
The Formula
Solar position equationsThe sunrise sunset formula uses the mathematical relationship: Solar position equations. Each variable in the formula represents a measurable quantity that affects the final result.
What Each Variable Means
Every value in the sunrise sunset formula, what it measures, and the value used in the worked example on this page:
| Variable | Type | Example value |
|---|---|---|
| Latitude (°N positive, °S negative) | Input (you provide) | 40.7 |
| Longitude (degrees, east positive, west negative) | Input (you provide) | -74.006 |
| Day of Year (1–365) | Input (you provide) | 172 |
| UTC Offset (hours) | Input (you provide) | -5 |
| Solar Declination (°) | Result (calculated) | — |
| Hour Angle at Sunrise (°) | Result (calculated) | — |
| Sunrise (decimal hour) | Result (calculated) | — |
| Sunset (decimal hour) | Result (calculated) | — |
| Daylight Duration (hours) | Result (calculated) | — |
| Solar Noon (decimal hour) | Result (calculated) | — |
Step-by-Step Method
- 1Write down the values you know: Latitude (°N positive, °S negative), Longitude (degrees, east positive, west negative), Day of Year (1–365), UTC Offset (hours).
- 2Substitute your known values into the formula: Solar position equations.
- 3Work through the arithmetic in the standard order of operations — parentheses first, then exponents, then multiplication and division, then addition and subtraction.
- 4Check that your result carries the correct unit and falls in a reasonable range for the problem.
- 5Verify your answer with the interactive Sunrise Sunset Calculator — it solves the same formula instantly.
Worked Example
Take a concrete case: latitude (°n positive, °s negative) = 20, with the other inputs at the typical values from the variables table above. Substituting into the formula gives solar declination (°) = 23.4520, hour angle at sunrise (°) = 100.0647, sunrise (decimal hour) = 5.2849, sunset (decimal hour) = 18.6269, daylight duration (hours) = 13.3420, solar noon (decimal hour) = 11.9559. These numbers are solved by the same engine that powers the Sunrise Sunset calculator, so you can reproduce them exactly by entering the same inputs there.
| Latitude (°N positive, °S negative) | Solar Declination (°) | Hour Angle at Sunrise (°) | Sunrise (decimal hour) | Sunset (decimal hour) | Daylight Duration (hours) | Solar Noon (decimal hour) |
|---|---|---|---|---|---|---|
| 10 | 23.4520 | 95.3124 | 5.6017 | 18.3100 | 12.7083 | 11.9559 |
| 20 | 23.4520 | 100.0647 | 5.2849 | 18.6269 | 13.3420 | 11.9559 |
| 30 | 23.4520 | 105.5907 | 4.9165 | 18.9953 | 14.0788 | 11.9559 |
| 40 | 23.4520 | 112.6253 | 4.4475 | 19.4642 | 15.0167 | 11.9559 |
| 50 | 23.4520 | 122.7965 | 3.7694 | 20.1423 | 16.3729 | 11.9559 |
| 60 | 23.4520 | 141.5442 | 2.5196 | 21.3922 | 18.8726 | 11.9559 |
| 80 | 23.4520 | — | — | — | — | 11.9559 |
| 100 | 23.4520 | — | — | — | — | 11.9559 |
| 200 | 23.4520 | 98.1076 | 5.4154 | 18.4964 | 13.0810 | 11.9559 |
How each result changes as latitude (°n positive, °s negative) changes, holding the other inputs constant.
Practice Problems
1. New York, summer solstice: Latitude (°N positive, °S negative) 40.7128, Longitude (degrees, east positive, west negative) -74.006, Day of Year (1–365) 172, UTC Offset (hours) -4 — work it out, then check the answer.
Answer: With Latitude (°N positive, °S negative) 40.7128, Longitude (degrees, east positive, west negative) -74.006, Day of Year (1–365) 172, UTC Offset (hours) -4, the results are Solar Declination (°) 23.4520, Hour Angle at Sunrise (°) 113.2172, Sunrise (decimal hour) 5.4081, Sunset (decimal hour) 20.5037, Daylight Duration (hours) 15.0956, and 1 more more results.
2. Plug in Latitude (°N positive, °S negative) 64.38, Longitude (degrees, east positive, west negative) -0.1278, Day of Year (1–365) 355, UTC Offset (hours) 0. What is the answer?
Answer: Entering Latitude (°N positive, °S negative) 64.38, Longitude (degrees, east positive, west negative) -0.1278, Day of Year (1–365) 355, UTC Offset (hours) 0 gives Solar Declination (°) -23.4199, Hour Angle at Sunrise (°) 29.9334, Sunrise (decimal hour) 9.9768, Sunset (decimal hour) 13.9679, Daylight Duration (hours) 3.9911, and 1 more more results.
Frequently Asked Questions
What is the formula for sunrise sunset?
The formula is: Solar position equations. Find sunrise and sunset times for any location and date.
What values do I need to calculate sunrise sunset?
You need latitude (°n positive, °s negative), longitude (degrees, east positive, west negative), day of year (1–365), utc offset (hours). The calculator produces solar declination (°), hour angle at sunrise (°), sunrise (decimal hour), sunset (decimal hour), daylight duration (hours), solar noon (decimal hour) from those inputs.
What is the sunrise sunset when latitude (°n positive, °s negative) is 20?
With latitude (°n positive, °s negative) = 20, the result is solar declination (°) = 23.4520, hour angle at sunrise (°) = 100.0647, sunrise (decimal hour) = 5.2849, sunset (decimal hour) = 18.6269, daylight duration (hours) = 13.3420, solar noon (decimal hour) = 11.9559. This is worked through in full in the example on this page.
Related Topics
Use the Interactive Calculator
Skip the manual math — get instant results with our free Sunrise Sunset calculator.
