-3

How does someone write a python function that converts a 'date' to the day of the year (e.g. Jan 31st would be the 'date' and 31 would be the day of year, Feb 1st would be the 'date' and 32 would be the day of year).

closed as off-topic by Dan C, nmtoken, Aaron Mar 16 '18 at 14:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    As this question is not GIS specific in any way, it would better fit on StackExchange's Programming site: StackOverflow. As a matter of fact, it is a question on StackOverflow, with some useful answers: stackoverflow.com/a/623312 – John Mar 16 '18 at 14:35
  • Look here and adjust at will – s6hebern Mar 17 '18 at 22:06
1

You can just format your date with %j

%j Day of the year as a zero-padded decimal number. 001, 002, …, 366

from datetime import date
today = date.today()
print today.strftime('%j')

Not the answer you're looking for? Browse other questions tagged or ask your own question.