toordinal()

toordinal : Return Proleptic Gregorian ordinal of the date starting with 1 as January 1 of year 1.

How ordinal is used to get date by using fromordinal()

Today's ordinal vlaue

from  datetime import date
my_ordinal=date.today().toordinal()
print("Today toordinal value : ",my_ordinal)
Output
Today toordinal value :  737319
Getting todays and tomorrows toordinal. We used timedelta here to get tomorrow's date object.
from datetime import date,datetime, timedelta 
print("Today toordinal : ",date.today().today().toordinal())
tomorrow=date.today() + timedelta(days=1)
print("Tomorrow toordinal : ",tomorrow.toordinal())
Output is here
Today toordinal :  737319
Tomorrow toordinal :  737320
We can create a date object and then get the value
import datetime
dt=datetime.datetime(2019,5,24) # Year , Month , date as input
print(dt.toordinal())
Output
737203
We can check the above data ( todays date )
dt=datetime.datetime(2019,9,16) # Year , Month , date as input
print(dt.toordinal())
Output
737318
All Date Objects
Your Rating




Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer