-1

I have a list of date in the format DD/MM/YYYY, I need to make a list of for example how many sunday's are in the original list, but I have absolutely no idea of where to start, my assignment says to use the datetime module. I am not looking for the answer but a general direction of where to start because at the moment I am lost.

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
VeraDJ
  • 29
  • 4
  • 3
    If you should use the `datetime` "module", then the bash tag is almost certainly wrong. Did you mean python? In that case [the docs for `datetime`](https://docs.python.org/3/library/datetime.html) are a good starting point. – L3viathan Feb 24 '21 at 13:10
  • @L3viathan yes I think so, let me change it. – VeraDJ Feb 24 '21 at 13:12
  • Does this answer your question? [How do I get the day of week given a date?](https://stackoverflow.com/questions/9847213/how-do-i-get-the-day-of-week-given-a-date) – Tomerikoo Feb 24 '21 at 13:16
  • if your input is string, see also [Python timestamp from day, month, year](https://stackoverflow.com/q/9223905/10197418) – FObersteiner Feb 24 '21 at 13:19

1 Answers1

1
import datetime
datetime.datetime(2021, 2, 24, 23, 13, 12).weekday() # Example 1
datetime.datetime.today().weekday()                  # Example 2

Returns an integer. Monday is zero, and so on.

Alex Metsai
  • 1,837
  • 5
  • 12
  • 24