Convert Calendar Date To Julian Date - Python
I am trying to convert calendar date like so: '2018-08-07' to julian calendar day like so '219'. I have tried for a long time and seem to run out of ideas. The julian day calendar
Solution 1:
You can use strftime
for this (see this for a description of directives to use):
jul = df.strftime('%j')
>>> jul
'219'
Solution 2:
def date_2_julian_string (date):
return str(date.strftime('%y')) + date.strftime('%j')
Post a Comment for "Convert Calendar Date To Julian Date - Python"