# Use Dates in Astronomical Calculations

Find the positions of the Sun and Moon at your current location.

 In[1]:= XSunPosition[Here, Now]
 Out[1]=
 In[2]:= XMoonPosition[Here, Now]
 Out[2]=

Plot the positions of the Sun and Moon on the celestial sphere.

 In[3]:= XEquatorialtoCartesian[ ra_, dec_] := { Cos[ra 15 \[Degree]] Sin[(dec + 90) \[Degree]], Sin[ra 15 \[Degree]] Sin[(dec + 90) \[Degree]], -Cos[(dec + 90) \[Degree]] }
 In[4]:= XShow[ ParametricPlot3D[{Cos[t] Sin[p], Sin[t] Sin[p], Cos[p]}, {t, 0, 2 Pi}, {p, 0, Pi}, PlotStyle -> {White, Opacity[.2]}, MeshStyle -> Black, Boxed -> False, Axes -> None, Background -> Black, Lighting -> "Neutral"], Graphics3D[{ Yellow, Sphere[EquatorialtoCartesian @@ QuantityMagnitude@ SunPosition[DateObject[Today], CelestialSystem -> "Equatorial"], .1], Gray, Sphere[ EquatorialtoCartesian @@ QuantityMagnitude@ MoonPosition[DateObject[Today], CelestialSystem -> "Equatorial"], .1]}], SphericalRegion -> True]
 Out[4]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »