from datetime import date
my_ordinal=date.today().toordinal()
print("Today toordinal value : ",my_ordinal)
print("Today date :",date.fromordinal(my_ordinal))
Output
Today toordinal value : 737319
Today date : 2019-09-17
Using today and tomorrow ordinal vlaue
from datetime import date,datetime,timedelta
from datetime import date
my_today=date.today().toordinal()
print("Today toordinal output : ",my_today)
my_tomorrow=date.today() + timedelta(days=1)
my_tomorrow=my_tomorrow.toordinal()
print("Tomorrow toordinal output : ",my_tomorrow)
print(date.fromordinal(my_today))
print(date.fromordinal(my_tomorrow))
Example 3: Convert Today's Date to Ordinal and Back
from datetime import date
today = date.today()
ordinal_value = today.toordinal() # Convert today's date to ordinal
print(date.fromordinal(ordinal_value)) # Output: Current date