DaylightQ[datespec]
gives True if it is daylight from the user's location on the specified datespec.
DaylightQ[locationspec,datespec]
gives True if it is daylight from the specified locationspec on the specified datespec.
DaylightQ
DaylightQ[datespec]
gives True if it is daylight from the user's location on the specified datespec.
DaylightQ[locationspec,datespec]
gives True if it is daylight from the specified locationspec on the specified datespec.
Details and Options
- For a given date, find out whether the Sun is illuminating a given location on Earth.
- The observation location can be any point on the surface of a body in the solar system, defining the local horizon.
- Locations can be specified as Entity objects, assuming they represent objects with geographic coordinates, or they can be latitude/longitude pairs, assuming degrees as units.
- DaylightQ[] makes use of $GeoLocation and $TimeZone to determine your location and time zone.
- datespec can be a DateObject expression, a TimeObject expression, a date string or a {y,m,d,h,m,s} date list.
- datespec is assumed to be in $TimeZone, unless it is a DateObject or TimeObject expression with an explicit TimeZone option value.
- locationspec and datespec can be either individual items or lists of them.
- If datespec is a list of dates, then the results will contain EventSeries objects.
- datespec can be specified as {start,end,increment} for compatibility with DateRange specifications.
- DaylightQ[…,inclusionspec] is used to specify how much of the locationspec must be in daylight.
- Possible settings for inclusionspec include:
-
"Everywhere" all of the locationspec must be in daylight "Somewhere" some of the locationspec must be in daylight "Nowhere" none of the locationspec must be in daylight - DaylightQ can accept the following option:
-
"SunAngleTest" (#>0&) function applied to the Sun altitude angle to determine if it is daylight
Examples
open all close allBasic Examples (5)
Determine if it is currently daylight for your location:
DaylightQ[]Determine if it is daylight for a specified date:
DaylightQ[DateObject[{2023, 3, 20, 11, 0}, TimeZone -> -5]]Determine if it is currently daylight for a specified location:
DaylightQ[["Chicago"]]Determine if it is daylight for a specified latitude/longitude and date:
DaylightQ[GeoPosition[{50.3, -80.1}], DateObject[{2023, 10, 1, 11, 0}, "Minute", "Gregorian", -5.]]Determine if it is currently daylight for a specified city and date:
DaylightQ[["Saint Louis"], DateObject[{2023, 10, 1, 11, 0}, "Minute", "Gregorian", -5.]]Scope (8)
Dates (3)
Dates can be specified as a DateObject:
DaylightQ[DateObject[{2023, 9, 23, 15, 0}, TimeZone -> "America/Chicago"]]Dates can be specified as a date string:
DaylightQ["September 23, 2022 3:00PM CDT"]Generate an event series that checks for daylight every 10 days in a year:
DaylightQ[DateRange[DateObject[{2023, 1, 1, 9, 0}, "Minute", "Gregorian", -5.], DateObject[{2023, 12, 31, 9, 0}, "Minute", "Gregorian", -5.], 10]]Locations (5)
Locations can be latitude/longitude pairs:
DaylightQ[GeoPosition[{40.1, -88.2}]]Locations can be relevant entities:
DaylightQ[["Saint Louis"]]Find the Sun's position for multiple locations:
DaylightQ[{["Chicago"], ["Tokyo"]}]LocalTimeZone[Entity["City", {"Tokyo", "Tokyo", "Japan"}]]Find the Sun's position for multiple locations on different dates:
DaylightQ[{{Entity["City", {"Chicago", "Illinois", "UnitedStates"}], DateObject[{2025, 1, 1, 12}, "Hour", "Gregorian", "America/Chicago"]}, {Entity["City", {"Tokyo", "Tokyo", "Japan"}], DateObject[{2025, 3, 14, 18, 0, 0}, "Instant", "Gregorian", "Asia/Tokyo"]}}]By default, extended locations must be fully in daylight in order to be True:
DaylightQ[["Russia"], DateObject[{2022, 4, 2, 10}, "Hour", "Gregorian", -5.]]DaylightQ[["Russia"], DateObject[{2022, 4, 2, 10}, "Hour", "Gregorian", -5.], "Everywhere"]The default behavior can be overridden to allow only part of the extended location to be in daylight:
DaylightQ[["Russia"], DateObject[{2022, 4, 2, 10}, "Hour", "Gregorian", -5.], "Somewhere"]Options (1)
"SunAngleTest" (1)
By default, it is considered daylight if the altitude angle of the Sun is greater than 0:
DaylightQ[GeoPosition[{40.1, -88.2}], DateObject[{2014, 4, 22, 20, 0, 0}, "Instant", "Gregorian", -5.]]SunPosition[GeoPosition[{40.1, -88.2}], DateObject[{2014, 4, 22, 20, 0, 0}, "Instant", "Gregorian", -5.]]The default behavior can be overridden to redefine what is meant by daylight:
DaylightQ[GeoPosition[{40.1, -88.2}], DateObject[{2014, 4, 22, 19, 30, 0}, "Instant", "Gregorian", -5.], "SunAngleTest" -> (# > -10&)]Properties & Relations (1)
Find whether it is daylight for this location and date:
loc = GeoPosition[{40.11, -88.22}];
date = DateObject[{2023, 7, 16, 12, 36, 0}];DaylightQ[loc, date]It is daylight if the Sun has a positive altitude:
SunPosition[loc, date]This can also be computed using AstroPosition:
AstroPosition[Entity["Star", "Sun"], {"Horizon", loc, date}]["Altitude"]See Also
Related Guides
Text
Wolfram Research (2014), DaylightQ, Wolfram Language function, https://reference.wolfram.com/language/ref/DaylightQ.html (updated 2023).
CMS
Wolfram Language. 2014. "DaylightQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2023. https://reference.wolfram.com/language/ref/DaylightQ.html.
APA
Wolfram Language. (2014). DaylightQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DaylightQ.html
BibTeX
@misc{reference.wolfram_2026_daylightq, author="Wolfram Research", title="{DaylightQ}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/DaylightQ.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_daylightq, organization={Wolfram Research}, title={DaylightQ}, year={2023}, url={https://reference.wolfram.com/language/ref/DaylightQ.html}, note=[Accessed: 12-June-2026]}